aboutsummaryrefslogtreecommitdiffstats
path: root/askama_derive/src
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-03-07 21:14:57 +0100
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-03-07 21:14:57 +0100
commit8d97f81880002ff3d8893869ce52e8684287a233 (patch)
treee846e8c335bfde257be0a703be320e54f1583a47 /askama_derive/src
parentd65d08b9378d23ba3fa5b66739f6c78de466fdb8 (diff)
downloadaskama-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.rs9
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