pub struct ErrorData {
pub code: ErrorCode,
pub message: Cow<'static, str>,
pub data: Option<Value>,
}
Expand description
Error information for JSON-RPC error responses.
This structure follows the JSON-RPC 2.0 specification for error reporting, providing a standardized way to communicate errors between clients and servers.
Fields§
§code: ErrorCode
The error type that occurred (using standard JSON-RPC error codes)
message: Cow<'static, str>
A short description of the error. The message SHOULD be limited to a concise single sentence.
data: Option<Value>
Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.).
Implementations§
Source§impl ErrorData
impl ErrorData
pub fn new( code: ErrorCode, message: impl Into<Cow<'static, str>>, data: Option<Value>, ) -> Self
pub fn resource_not_found( message: impl Into<Cow<'static, str>>, data: Option<Value>, ) -> Self
pub fn parse_error( message: impl Into<Cow<'static, str>>, data: Option<Value>, ) -> Self
pub fn invalid_request( message: impl Into<Cow<'static, str>>, data: Option<Value>, ) -> Self
pub fn method_not_found<M: ConstString>() -> Self
pub fn invalid_params( message: impl Into<Cow<'static, str>>, data: Option<Value>, ) -> Self
pub fn internal_error( message: impl Into<Cow<'static, str>>, data: Option<Value>, ) -> Self
Trait Implementations§
Source§impl<'de> Deserialize<'de> for ErrorData
impl<'de> Deserialize<'de> for ErrorData
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
Source§impl Error for ErrorData
impl Error for ErrorData
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns 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 JsonSchema for ErrorData
impl JsonSchema for ErrorData
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref
keyword. Read moreimpl StructuralPartialEq for ErrorData
Auto Trait Implementations§
impl Freeze for ErrorData
impl RefUnwindSafe for ErrorData
impl Send for ErrorData
impl Sync for ErrorData
impl Unpin for ErrorData
impl UnwindSafe for ErrorData
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string
, but without panic on OOM.