This commit is contained in:
2026-04-21 19:17:31 +08:00
parent d234d27cc0
commit 89129ef1f4
83 changed files with 13329 additions and 176 deletions

View File

@@ -1,6 +1,6 @@
use axum::{
http::{HeaderMap, HeaderValue},
http::StatusCode,
http::{HeaderMap, HeaderValue},
response::{IntoResponse, Response},
};
use serde::Serialize;
@@ -42,6 +42,10 @@ impl AppError {
self.code
}
pub fn message(&self) -> &str {
&self.message
}
pub fn with_message(mut self, message: impl Into<String>) -> Self {
self.message = message.into();
self
@@ -60,7 +64,8 @@ impl AppError {
pub fn into_response_with_context(self, request_context: Option<&RequestContext>) -> Response {
let status_code = self.status_code;
let payload = self.to_payload();
let mut response = (status_code, json_error_body(request_context, &payload)).into_response();
let mut response =
(status_code, json_error_body(request_context, &payload)).into_response();
response.headers_mut().extend(self.headers);
response
}