pub struct Error {
pub code: i32,
pub message: String,
pub data: Option<Box<RawValue>>,
}Expand description
A JSON-RPC 2.0 error object.
code and message are required. data is optional and MAY contain
additional structured information about the error.
Fields§
§code: i32The error code. Pre-defined codes use the range -32768 to -32000.
message: StringA short single-sentence description of the error.
data: Option<Box<RawValue>>Optional additional error data.
Implementations§
Source§impl Error
impl Error
Sourcepub fn new(code: i32, message: impl Into<String>) -> Self
pub fn new(code: i32, message: impl Into<String>) -> Self
Creates a new Error with the given code and message.
Sourcepub fn with_data(
code: i32,
message: impl Into<String>,
data: impl Serialize,
) -> Result<Self>
pub fn with_data( code: i32, message: impl Into<String>, data: impl Serialize, ) -> Result<Self>
Creates a new Error with additional data.
Sourcepub fn parse_error() -> Self
pub fn parse_error() -> Self
Creates a parse error response.
Sourcepub fn invalid_request(message: impl Into<String>) -> Self
pub fn invalid_request(message: impl Into<String>) -> Self
Creates an invalid request error response.
Sourcepub fn method_not_found(method: impl Into<String>) -> Self
pub fn method_not_found(method: impl Into<String>) -> Self
Creates a method not found error response.
Sourcepub fn invalid_params(message: impl Into<String>) -> Self
pub fn invalid_params(message: impl Into<String>) -> Self
Creates an invalid params error response.
Sourcepub fn internal_error() -> Self
pub fn internal_error() -> Self
Creates an internal error response.
Sourcepub fn is_reserved_code(&self) -> bool
pub fn is_reserved_code(&self) -> bool
Returns true if this error uses a reserved pre-defined code.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Error
impl<'de> Deserialize<'de> for Error
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Error
impl RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
impl UnwindSafe for Error
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more