diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-03-07 21:14:57 +0100 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-03-07 21:14:57 +0100 |
commit | 8d97f81880002ff3d8893869ce52e8684287a233 (patch) | |
tree | e846e8c335bfde257be0a703be320e54f1583a47 /askama_derive | |
parent | d65d08b9378d23ba3fa5b66739f6c78de466fdb8 (diff) | |
download | askama-8d97f81880002ff3d8893869ce52e8684287a233.tar.gz askama-8d97f81880002ff3d8893869ce52e8684287a233.tar.bz2 askama-8d97f81880002ff3d8893869ce52e8684287a233.zip |
Panic with better message if template not found (fixes #4)
Diffstat (limited to '')
-rw-r--r-- | askama_derive/src/path.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/askama_derive/src/path.rs b/askama_derive/src/path.rs index 96ed8c1..aac6557 100644 --- a/askama_derive/src/path.rs +++ b/askama_derive/src/path.rs @@ -12,7 +12,14 @@ fn template_dir() -> PathBuf { pub fn get_template_source(tpl_file: &str) -> String { let mut path = template_dir(); path.push(Path::new(tpl_file)); - let mut f = File::open(path).unwrap(); + let mut f = match File::open(&path) { + Err(_) => { + let msg = format!("unable to open template file '{}'", + &path.to_str().unwrap()); + panic!(msg); + }, + Ok(f) => f, + }; let mut s = String::new(); f.read_to_string(&mut s).unwrap(); s |