mirror of
https://git.proxmox.com/git/proxmox
synced 2025-05-01 04:26:12 +00:00
macro: more error handling improvements
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
9c9413ae56
commit
43d69cb1aa
@ -535,7 +535,9 @@ fn handle_named_struct_fields(
|
|||||||
|
|
||||||
let def = field_def
|
let def = field_def
|
||||||
.remove(&name_str)
|
.remove(&name_str)
|
||||||
.ok_or_else(|| format_err!("missing field in definition: '{}'", name_str))?
|
.ok_or_else(|| {
|
||||||
|
c_format_err!(name.span(), "missing field in definition: '{}'", name_str)
|
||||||
|
})?
|
||||||
.expect_object()?;
|
.expect_object()?;
|
||||||
|
|
||||||
let def = ParameterDefinition::from_object(def)?;
|
let def = ParameterDefinition::from_object(def)?;
|
||||||
@ -544,14 +546,19 @@ fn handle_named_struct_fields(
|
|||||||
|
|
||||||
if !field_def.is_empty() {
|
if !field_def.is_empty() {
|
||||||
// once SliceConcatExt is stable we can join(",") on the fields...
|
// once SliceConcatExt is stable we can join(",") on the fields...
|
||||||
|
let mut span = None;
|
||||||
let mut missing = String::new();
|
let mut missing = String::new();
|
||||||
for key in field_def.keys() {
|
for key in field_def.keys() {
|
||||||
if !missing.is_empty() {
|
if !missing.is_empty() {
|
||||||
missing.push_str(", ");
|
missing.push_str(", ");
|
||||||
}
|
}
|
||||||
|
if span.is_none() {
|
||||||
|
span = Some(key.span());
|
||||||
|
}
|
||||||
missing.push_str(key.as_str());
|
missing.push_str(key.as_str());
|
||||||
}
|
}
|
||||||
bail!(
|
c_bail!(
|
||||||
|
span.unwrap(),
|
||||||
"the following struct fields are not handled in the api definition: {}",
|
"the following struct fields are not handled in the api definition: {}",
|
||||||
missing
|
missing
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user