Struct prost_twirp::TwirpError
source · pub struct TwirpError {
pub status: StatusCode,
pub error_type: String,
pub msg: String,
pub meta: Option<Value>,
}
Expand description
A JSON-serializable Twirp error
Fields§
§status: StatusCode
§error_type: String
§msg: String
§meta: Option<Value>
Implementations§
source§impl TwirpError
impl TwirpError
sourcepub fn new(status: StatusCode, error_type: &str, msg: &str) -> TwirpError
pub fn new(status: StatusCode, error_type: &str, msg: &str) -> TwirpError
Create a Twirp error with no meta
sourcepub fn new_meta(
status: StatusCode,
error_type: &str,
msg: &str,
meta: Option<Value>
) -> TwirpError
pub fn new_meta(
status: StatusCode,
error_type: &str,
msg: &str,
meta: Option<Value>
) -> TwirpError
Create a Twirp error with optional meta
sourcepub fn to_hyper_response(&self) -> Response<Body>
pub fn to_hyper_response(&self) -> Response<Body>
Create a hyper response for this error and the given status code
sourcepub fn from_json(status: StatusCode, json: Value) -> TwirpError
pub fn from_json(status: StatusCode, json: Value) -> TwirpError
Create error from Serde JSON value
sourcepub fn from_json_bytes(status: StatusCode, json: &[u8]) -> Result<TwirpError>
pub fn from_json_bytes(status: StatusCode, json: &[u8]) -> Result<TwirpError>
Create error from byte array
sourcepub fn to_json_bytes(&self) -> Result<Vec<u8>>
pub fn to_json_bytes(&self) -> Result<Vec<u8>>
Create byte array from error
Trait Implementations§
source§impl Clone for TwirpError
impl Clone for TwirpError
source§fn clone(&self) -> TwirpError
fn clone(&self) -> TwirpError
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for TwirpError
impl Debug for TwirpError
source§impl Display for TwirpError
impl Display for TwirpError
source§impl Error for TwirpError
impl Error for TwirpError
1.30.0 · source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
The lower-level source of this error, if any. Read more
1.0.0 · source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
source§impl From<TwirpError> for ProstTwirpError
impl From<TwirpError> for ProstTwirpError
source§fn from(v: TwirpError) -> ProstTwirpError
fn from(v: TwirpError) -> ProstTwirpError
Converts to this type from the input type.