pub struct BoxError { /* private fields */ }Expand description
Structured info about an error which can happen as a result of an internal API or a remote procedure call.
Can also be used in user code to return structured error info from stored procedures.
Implementations§
Source§impl BoxError
impl BoxError
Sourcepub fn new(code: impl Into<u32>, message: impl Into<String>) -> Self
pub fn new(code: impl Into<u32>, message: impl Into<String>) -> Self
Construct an error object with given error code and message. The
resulting error will have file & line fields set from the caller’s
location.
Use Self::with_location to override error location.
Sourcepub fn with_location(
code: impl Into<u32>,
message: impl Into<String>,
file: impl Into<String>,
line: u32,
) -> Self
pub fn with_location( code: impl Into<u32>, message: impl Into<String>, file: impl Into<String>, line: u32, ) -> Self
Construct an error object with given error code and message and
source location.
Use Self::new to use the caller’s location.
Sourcepub fn maybe_last() -> Result<(), Self>
pub fn maybe_last() -> Result<(), Self>
Tries to get the information about the last API call error. If error was not set
returns Ok(())
Sourcepub unsafe fn from_ptr(error_ptr: NonNull<BoxError>) -> Self
pub unsafe fn from_ptr(error_ptr: NonNull<BoxError>) -> Self
Create a BoxError from a poniter to the underlying struct.
Use Self::maybe_last to automatically get the last error set by tarantool.
§Safety
The pointer must point to a valid struct of type BoxError.
Also must only be called from the tx thread.
Sourcepub fn set_last(&self)
pub fn set_last(&self)
Set self as the last API call error.
Useful when returning errors from stored prcoedures.
Sourcepub fn error_code(&self) -> u32
pub fn error_code(&self) -> u32
Return IPROTO error code
Sourcepub fn error_type(&self) -> &str
pub fn error_type(&self) -> &str
Return the error type, e.g. “ClientError”, “SocketError”, etc.
Sourcepub fn file(&self) -> Option<&str>
pub fn file(&self) -> Option<&str>
Return the name of the source file where the error was created, if it’s available.
Sourcepub fn line(&self) -> Option<u32>
pub fn line(&self) -> Option<u32>
Return the source line number where the error was created, if it’s available.
Sourcepub fn errno(&self) -> Option<u32>
pub fn errno(&self) -> Option<u32>
Return the system errno value of the cause of this error,
if it’s available.
You can use std::io::Error::from_raw_os_error to get more details
for the returned error code.
Trait Implementations§
Source§impl IntoBoxError for BoxError
impl IntoBoxError for BoxError
Source§fn set_last_error(self)
fn set_last_error(self)
self as the current fiber’s last error.Source§fn into_box_error(self) -> BoxError
fn into_box_error(self) -> BoxError
self to BoxError.