inline problem_details builder at call sites; drop the one-caller wrapper
This commit is contained in:
parent
cdf1bfe7db
commit
2b0c51badf
8 changed files with 79 additions and 78 deletions
|
|
@ -1657,24 +1657,18 @@ fn strip_container_prefix(name: &str) -> String {
|
|||
.to_owned()
|
||||
}
|
||||
|
||||
/// Build an RFC 9457 (`application/problem+json`) error response via the
|
||||
/// Convenience wrapper for the common internal-error case: a 500
|
||||
/// RFC 9457 (`application/problem+json`) response via the
|
||||
/// `problem_details` crate. `from_status_code` sets `status` + `title`
|
||||
/// (the canonical reason phrase) and leaves `type` as the default
|
||||
/// `about:blank`; `with_detail` carries the caller message. The crate's
|
||||
/// axum `IntoResponse` emits the body with the `application/problem+json`
|
||||
/// content type. Centralising this keeps every dashboard error on one
|
||||
/// machine-readable shape the frontend parses (it reads `detail`).
|
||||
fn problem_response(status: StatusCode, detail: &str) -> Response {
|
||||
problem_details::ProblemDetails::from_status_code(status)
|
||||
.with_detail(detail)
|
||||
/// `about:blank`; `with_detail` carries the caller message; the crate's
|
||||
/// axum `IntoResponse` emits the `application/problem+json` body the
|
||||
/// frontend parses (it reads `detail`). Most dashboard handlers funnel
|
||||
/// their errors through here; handlers with a more specific client
|
||||
/// failure (bad input, not found) build the same `ProblemDetails`
|
||||
/// inline with the right status.
|
||||
fn error_response(message: &str) -> Response {
|
||||
problem_details::ProblemDetails::from_status_code(StatusCode::INTERNAL_SERVER_ERROR)
|
||||
.with_detail(message)
|
||||
.into_response()
|
||||
}
|
||||
|
||||
/// Convenience wrapper for the common internal-error case: a 500
|
||||
/// problem-details response (see [`problem_response`]). Most dashboard
|
||||
/// handlers funnel their errors through here; handlers with a more
|
||||
/// specific failure (bad input, not found) call [`problem_response`]
|
||||
/// directly with the right status.
|
||||
fn error_response(message: &str) -> Response {
|
||||
problem_response(StatusCode::INTERNAL_SERVER_ERROR, message)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue