mirror of
https://github.com/hinto-janai/cuprate.git
synced 2024-12-23 03:59:37 +00:00
fn error() -> String
-> error!() -> &'static str
This commit is contained in:
parent
3665c80b25
commit
40a831413b
1 changed files with 11 additions and 6 deletions
|
@ -291,8 +291,13 @@ impl EpeeObjectBuilder<GetBlocksResponse> for __GetBlocksResponseEpeeBuilder {
|
||||||
|
|
||||||
fn finish(self) -> error::Result<GetBlocksResponse> {
|
fn finish(self) -> error::Result<GetBlocksResponse> {
|
||||||
/// The error returned when a required field is missing.
|
/// The error returned when a required field is missing.
|
||||||
fn error(name: &'static str) -> error::Error {
|
macro_rules! error {
|
||||||
error::Error::Value(format!("Required field was not found: {name}"))
|
($field_name:literal) => {
|
||||||
|
error::Error::Format(concat!(
|
||||||
|
"Required field was not found: ",
|
||||||
|
stringify!($field_name)
|
||||||
|
))
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// INVARIANT:
|
// INVARIANT:
|
||||||
|
@ -302,11 +307,11 @@ impl EpeeObjectBuilder<GetBlocksResponse> for __GetBlocksResponseEpeeBuilder {
|
||||||
|
|
||||||
// Deserialize the common fields.
|
// Deserialize the common fields.
|
||||||
let header = GetBlocksResponseHeader {
|
let header = GetBlocksResponseHeader {
|
||||||
status: self.status.ok_or_else(|| error("status"))?,
|
status: self.status.ok_or(error!("status"))?,
|
||||||
untrusted: self.untrusted.ok_or_else(|| error("untrusted"))?,
|
untrusted: self.untrusted.ok_or(error!("untrusted"))?,
|
||||||
blocks: self.blocks.unwrap_or_default(),
|
blocks: self.blocks.unwrap_or_default(),
|
||||||
start_height: self.start_height.ok_or_else(|| error("start_height"))?,
|
start_height: self.start_height.ok_or(error!("start_height"))?,
|
||||||
current_height: self.current_height.ok_or_else(|| error("current_height"))?,
|
current_height: self.current_height.ok_or(error!("current_height"))?,
|
||||||
output_indices: self.output_indices.unwrap_or_default(),
|
output_indices: self.output_indices.unwrap_or_default(),
|
||||||
daemon_time: self.daemon_time.unwrap_or_default(),
|
daemon_time: self.daemon_time.unwrap_or_default(),
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue