pub struct Error<T = Value> {
pub code: i64,
pub message: String,
pub data: Option<T>,
}Expand description
A JSON-RPC 2.0 error object.
Fields§
§code: i64A Number that indicates the error type that occurred. This MUST be an integer.
See the associated constants for error types defined by the specification.
message: StringA String providing a short description of the error. The message SHOULD be limited to a concise single sentence.
data: Option<T>A Primitive or Structured value that contains additional information about the error. This may be omitted. The value of this member is defined by the Server (e.g. detailed error information, nested errors etc.).
Implementations§
Source§impl Error
impl Error
Sourcepub const PARSE_ERROR: i64 = -32_700i64
pub const PARSE_ERROR: i64 = -32_700i64
Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text.
Sourcepub const INVALID_REQUEST: i64 = -32_600i64
pub const INVALID_REQUEST: i64 = -32_600i64
The JSON sent is not a valid Request object.
Sourcepub const METHOD_NOT_FOUND: i64 = -32_601i64
pub const METHOD_NOT_FOUND: i64 = -32_601i64
The method does not exist / is not available.
Sourcepub const INVALID_PARAMS: i64 = -32_602i64
pub const INVALID_PARAMS: i64 = -32_602i64
Invalid method parameter(s).
Sourcepub const INTERNAL_ERROR: i64 = -32_603i64
pub const INTERNAL_ERROR: i64 = -32_603i64
Internal JSON-RPC error.
Source§impl<T> Error<T>
impl<T> Error<T>
Sourcepub fn parse_error(
message: impl Display,
data: impl Into<Option<T>>,
) -> Error<T>
pub fn parse_error( message: impl Display, data: impl Into<Option<T>>, ) -> Error<T>
Convenience method for creating a new error with code Self::PARSE_ERROR
Sourcepub fn invalid_request(
message: impl Display,
data: impl Into<Option<T>>,
) -> Error<T>
pub fn invalid_request( message: impl Display, data: impl Into<Option<T>>, ) -> Error<T>
Convenience method for creating a new error with code Self::INVALID_REQUEST
Sourcepub fn method_not_found(
message: impl Display,
data: impl Into<Option<T>>,
) -> Error<T>
pub fn method_not_found( message: impl Display, data: impl Into<Option<T>>, ) -> Error<T>
Convenience method for creating a new error with code Self::METHOD_NOT_FOUND
Sourcepub fn invalid_params(
message: impl Display,
data: impl Into<Option<T>>,
) -> Error<T>
pub fn invalid_params( message: impl Display, data: impl Into<Option<T>>, ) -> Error<T>
Convenience method for creating a new error with code Self::INVALID_PARAMS
Sourcepub fn internal_error(
message: impl Display,
data: impl Into<Option<T>>,
) -> Error<T>
pub fn internal_error( message: impl Display, data: impl Into<Option<T>>, ) -> Error<T>
Convenience method for creating a new error with code Self::INTERNAL_ERROR
Sourcepub const fn spec_message(&self) -> Option<&'static str>
pub const fn spec_message(&self) -> Option<&'static str>
If Self::code is one of the predefined errors in the spec,
get its associated error message.
Source§impl Error
impl Error
Sourcepub const SERVER_ERROR_RANGE: RangeInclusive<i64>
pub const SERVER_ERROR_RANGE: RangeInclusive<i64>
Reserved for implementation-defined server-errors.