pub struct ForeignError {
pub code: i32,
pub message: String,
pub payload: Vec<u8>,
}Expand description
A failure a consumer’s callback-interface implementation reported, or a value it returned that the producer couldn’t accept.
Every callback trait method returns Result<T, ForeignError>. code is
FOREIGN_ERROR_CODE for any consumer failure, except that a method
declared throws keeps a code of its module’s error domain, whose fields
domain decodes. A malformed return value (a string that
isn’t UTF-8, a null object, a bad enum value or buffer) has the code
MARSHAL_ERROR_CODE.
Fields§
§code: i32The failure’s code (see the type’s docs).
message: StringThe consumer’s message, copied out of out_err before it was freed.
payload: Vec<u8>The domain code’s fields as a value buffer, or empty.
Implementations§
Source§impl ForeignError
impl ForeignError
Sourcepub fn new(code: i32, message: impl Into<String>) -> Self
pub fn new(code: i32, message: impl Into<String>) -> Self
A failure with code and message and no payload.
Sourcepub fn domain<E: ErrorDomain>(&self) -> Option<E>
pub fn domain<E: ErrorDomain>(&self) -> Option<E>
Decode a domain error the consumer reported: Some when code is
one of E’s declared codes and the payload holds that code’s fields.
Object fields can’t be decoded here (a callback’s error payload may
not carry object references), so a code whose fields include an
interface yields None.
Trait Implementations§
Source§impl Clone for ForeignError
impl Clone for ForeignError
Source§fn clone(&self) -> ForeignError
fn clone(&self) -> ForeignError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ForeignError
impl Debug for ForeignError
Source§impl Display for ForeignError
impl Display for ForeignError
impl Eq for ForeignError
Source§impl Error for ForeignError
impl Error for ForeignError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl ErrorReport for ForeignError
A ForeignError is reported with its own code, message, and payload, so
a producer function whose error type is ForeignError can propagate a
callback failure with ?.
impl ErrorReport for ForeignError
A ForeignError is reported with its own code, message, and payload, so
a producer function whose error type is ForeignError can propagate a
callback failure with ?.
Source§fn code(&self) -> i32
fn code(&self) -> i32
FfiError::code. Defaults to
GENERIC_ERROR_CODE.Source§fn message(&self) -> String
fn message(&self) -> String
FfiError::message.