summaryrefslogtreecommitdiff
path: root/src/template.rs
diff options
context:
space:
mode:
authortroido <troido@protonmail.com>2020-04-06 19:28:45 +0200
committertroido <troido@protonmail.com>2020-04-06 19:28:45 +0200
commit7c351a0c7a497d30f4826a19e6c6e92d3e7b5065 (patch)
tree26add4ae11f03b2435c149ef5fe95d66afd60eda /src/template.rs
parent66a3d3131f32e7bae2f0f7c4fd0b0c876eb3e8a0 (diff)
improved error handling
Diffstat (limited to 'src/template.rs')
-rw-r--r--src/template.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/template.rs b/src/template.rs
index 850a323..dbaec93 100644
--- a/src/template.rs
+++ b/src/template.rs
@@ -63,11 +63,11 @@ impl Template {
let name = EntityType(val.get("type").ok_or(perr!("template doesn't have 'type'"))?.as_str().ok_or(perr!("template type not a string"))?.to_string());
let mut args = Vec::new();
for arg in val.get("args").unwrap_or(&json!([])).as_array().ok_or(perr!("template args not an array"))? {
- args.push(Parameter::guess_from_json(arg).ok_or(perr!("template arg not a parameter"))?);
+ args.push(Parameter::guess_from_json(arg).ok_or(perr!("template arg {:?} not a parameter", arg))?);
}
let mut kwargs = HashMap::new();
for (key, arg) in val.get("kwargs").unwrap_or(&json!({})).as_object().ok_or(perr!("template kwargs not a json object"))? {
- kwargs.insert(key.to_string(), Parameter::guess_from_json(arg).ok_or(perr!("template arg not a parameter"))?);
+ kwargs.insert(key.to_string(), Parameter::guess_from_json(arg).ok_or(perr!("template kwarg {}: {:?} not a parameter", key, arg))?);
}
let save = val.get("save").unwrap_or(&json!(true)).as_bool().ok_or(perr!("save not a bool"))?;
Ok(Template {name, args, kwargs, save})