diff options
-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 |