macro_rules! bail_public {
(_, $($arg:tt)*) => { ... };
($code:expr) => { ... };
($code:expr, $fmt:literal $(,)?) => { ... };
($code:expr, $fmt:literal, $($arg:tt)*) => { ... };
}
Expand description
Returns early with a message that will be exposed externally through JSON-RPC
Specifies an error code and a message using the same format as std::format!
.
Using _
instead of an error code will use ErrorCode::INTERNAL_ERROR
.
Equivalent to return Err(Error::new(code).with_message(format!(...), true))
ยงExamples
bail_public!(_, "Invalid request");
bail_public!(ErrorCode::INVALID_REQUEST, "Invalid request");
bail_public!(ErrorCode::INVALID_REQUEST, "Invalid request: {}", 1);