mirror of
https://git.proxmox.com/git/proxmox
synced 2025-08-04 19:02:23 +00:00
api-macro: reduce code output a little
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
881df81976
commit
03012deb3f
@ -607,7 +607,7 @@ fn create_wrapper_function(
|
||||
let #arg_name = input_map
|
||||
.remove(#name_str)
|
||||
.map(::serde_json::from_value)
|
||||
.transpose()?;
|
||||
.transpose()?
|
||||
});
|
||||
if !optional {
|
||||
// Non-optional types need to be extracted out of the option though:
|
||||
@ -616,15 +616,13 @@ fn create_wrapper_function(
|
||||
// verifier already, so here we just use failure::bail! instead of building a
|
||||
// proper http error!
|
||||
body.extend(quote_spanned! { span =>
|
||||
let #arg_name = match #arg_name {
|
||||
Some(v) => v,
|
||||
None => ::failure::bail!(
|
||||
.ok_or_else(|| ::failure::format_err!(
|
||||
"missing non-optional parameter: {}",
|
||||
#name_str,
|
||||
),
|
||||
};
|
||||
))?
|
||||
});
|
||||
}
|
||||
body.extend(quote_spanned! { span => ; });
|
||||
args.extend(quote_spanned! { span => #arg_name, });
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user