pub struct Error { /* private fields */ }
Expand description
Represents a JSON-RPC error that the server may send as a response.
This type contains both the standard JSON-RPC error fields (code, message, data)
and an optional std::error::Error
source for additional context. Depending on
the build configuration (cfg!(debug_assertions)
) or certain Session
settings,
debug builds typically include the source error to facilitate troubleshooting,
while release builds omit it to prevent leaking internal information.
§Notes
- This error type can be automatically created from any
std::error::Error
using the?
operator, similarly toanyhow
. - Serialization is intentionally not implemented. This prevents unintended usage
of
Result<T>
whereT
might be handled byRequestContext::handle
orRequestContext::handle_async
, avoiding subtle bugs. - For JSON-RPC errors received from a server, see
SessionError
.
Implementations§
Source§impl Error
impl Error
pub fn new(code: ErrorCode) -> Error
pub fn with_message(self, message: impl Display, is_public: bool) -> Error
pub fn with_source(self, source: impl Error + Send + Sync + 'static) -> Error
pub fn backtrace(&self) -> &Backtrace
pub fn source(&self) -> Option<&(dyn Error + Sync + Send + 'static)>
pub fn to_error_object(&self, expose_internals: bool) -> ErrorObject
Trait Implementations§
Source§impl From<ErrorObject> for Error
impl From<ErrorObject> for Error
Source§fn from(e: ErrorObject) -> Error
fn from(e: ErrorObject) -> Error
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for Error
impl !RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin 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