pub struct Problem {
pub type_url: String,
pub title: String,
pub status: StatusCode,
pub detail: String,
pub instance: String,
pub code: String,
pub trace_id: Option<String>,
pub errors: Option<Vec<ValidationViolation>>,
}Expand description
RFC 9457 Problem Details for HTTP APIs.
Fields§
§type_url: StringA URI reference that identifies the problem type. When dereferenced, it might provide human-readable documentation.
title: StringA short, human-readable summary of the problem type.
status: StatusCodeThe HTTP status code for this occurrence of the problem. Serializes as u16 for RFC 9457 compatibility.
detail: StringA human-readable explanation specific to this occurrence of the problem.
instance: StringA URI reference that identifies the specific occurrence of the problem.
code: StringOptional machine-readable error code defined by the application.
trace_id: Option<String>Optional trace id useful for tracing.
errors: Option<Vec<ValidationViolation>>Optional validation errors for 4xx problems.
Implementations§
Source§impl Problem
impl Problem
Sourcepub fn new(
status: StatusCode,
title: impl Into<String>,
detail: impl Into<String>,
) -> Self
pub fn new( status: StatusCode, title: impl Into<String>, detail: impl Into<String>, ) -> Self
Create a new Problem with the given status, title, and detail.
Note: This function accepts http::StatusCode for type safety.
The status is serialized as u16 for RFC 9457 compatibility.