pub struct GuestError {
pub code: String,
pub message: String,
pub detail: Option<Vec<u8>>,
pub retry_after_ms: Option<u64>,
}Expand description
A structured error crossing the guest boundary — returned by a guest
through circlet.fail, or handed back to a caller by circlet.invoke
(InvokeError).
Circlet itself is policy-free and payload-agnostic: it never interprets
code or detail. The embedder owns the error vocabulary (code) and
the encoding of detail bytes (JSON, CBOR, or none), while Circlet
guarantees the structured error crosses the Wasm boundary intact without
colliding with output payloads or flattening to a single string.
Fields§
§code: StringMachine-readable error code in the embedder’s vocabulary
(for example "invalid", "not_found", "conflict", "busy").
message: StringHuman-readable explanation of what failed.
detail: Option<Vec<u8>>Optional structured detail bytes, opaque to Circlet.
retry_after_ms: Option<u64>Optional hint of how long to wait before retrying, in milliseconds.
Implementations§
Source§impl GuestError
impl GuestError
Sourcepub fn new(code: impl Into<String>, message: impl Into<String>) -> Self
pub fn new(code: impl Into<String>, message: impl Into<String>) -> Self
Construct a structured error with a machine-readable code and
explanation message.
Sourcepub fn message(message: impl Into<String>) -> Self
pub fn message(message: impl Into<String>) -> Self
Construct a plain failure with code "failed".
Sourcepub fn with_detail(self, detail: impl Into<Vec<u8>>) -> Self
pub fn with_detail(self, detail: impl Into<Vec<u8>>) -> Self
Attach opaque structured detail bytes to this error.
Sourcepub fn with_retry_after_ms(self, retry_after_ms: u64) -> Self
pub fn with_retry_after_ms(self, retry_after_ms: u64) -> Self
Attach a retry hint in milliseconds to this error.
Sourcepub fn detail_str(&self) -> Option<&str>
pub fn detail_str(&self) -> Option<&str>
View detail as UTF-8 text when present and valid UTF-8.
Trait Implementations§
Source§impl Clone for GuestError
impl Clone for GuestError
Source§impl Debug for GuestError
impl Debug for GuestError
Source§impl Default for GuestError
impl Default for GuestError
Source§impl<'de> Deserialize<'de> for GuestError
impl<'de> Deserialize<'de> for GuestError
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>,
Source§impl Display for GuestError
impl Display for GuestError
impl Eq for GuestError
Source§impl Error for GuestError
impl Error for GuestError
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()