pub struct Problem {
pub problem_type: String,
pub title: String,
pub status: u16,
pub detail: String,
pub instance: Option<String>,
pub trace_id: Option<String>,
pub context: Value,
}Fields§
§problem_type: String§title: String§status: u16§detail: String§instance: Option<String>§trace_id: Option<String>§context: ValueImplementations§
Source§impl Problem
impl Problem
Sourcepub fn from_error(err: &CanonicalError) -> Result<Self, Error>
pub fn from_error(err: &CanonicalError) -> Result<Self, Error>
Convert a CanonicalError to a Problem.
§Errors
Returns serde_json::Error if the error-category context type
fails to serialize. Built-in context types are plain structs and
should never fail, but this keeps the failure visible rather than
silently producing an empty "context": {}.
Sourcepub fn from_error_debug(err: &CanonicalError) -> Result<Self, Error>
pub fn from_error_debug(err: &CanonicalError) -> Result<Self, Error>
Convert a CanonicalError to a Problem, including the internal
diagnostic string in the context for Internal and Unknown
variants.
This method MUST NOT be used in production. It exists so that development and test environments can surface the real error cause in the wire response for easier debugging.
In production, use from_error instead — it
never leaks the diagnostic string.
§Errors
Returns serde_json::Error if the context fails to serialize.
Sourcepub fn with_trace_id(self, trace_id: impl Into<String>) -> Self
pub fn with_trace_id(self, trace_id: impl Into<String>) -> Self
Set the trace_id field, returning self for chaining.
Sourcepub fn with_instance(self, instance: impl Into<String>) -> Self
pub fn with_instance(self, instance: impl Into<String>) -> Self
Set the instance field, returning self for chaining.