macro: improved error output

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2019-07-19 09:58:07 +02:00
parent 183125b1cd
commit bb673ec0db

View File

@ -105,6 +105,7 @@ impl ParameterDefinition {
pub fn from_object(obj: Object) -> Result<Self, Error> {
let mut def = ParameterDefinition::builder();
let obj_span = obj.span();
for (key, value) in obj {
match key.as_str() {
"description" => {
@ -119,13 +120,13 @@ impl ParameterDefinition {
"maximum" => {
def.maximum(Some(value.expect_expr()?));
}
other => bail!("invalid key in type definition: {}", other),
other => c_bail!(key.span(), "invalid key in type definition: {}", other),
}
}
match def.build() {
Ok(r) => Ok(r),
Err(err) => bail!("{}", err),
Err(err) => c_bail!(obj_span, "{}", err),
}
}