systemprompt_api/error/
mod.rs1mod conversions;
17
18use axum::response::{IntoResponse, Response};
19use systemprompt_models::api::ApiError;
20
21#[derive(Debug)]
22pub struct ApiHttpError(ApiError);
23
24impl ApiHttpError {
25 pub fn not_found(message: impl Into<String>) -> Self {
26 Self(ApiError::not_found(message))
27 }
28
29 pub fn bad_request(message: impl Into<String>) -> Self {
30 Self(ApiError::bad_request(message))
31 }
32
33 pub fn unauthorized(message: impl Into<String>) -> Self {
34 Self(ApiError::unauthorized(message))
35 }
36
37 pub fn forbidden(message: impl Into<String>) -> Self {
38 Self(ApiError::forbidden(message))
39 }
40
41 pub fn internal_error(message: impl Into<String>) -> Self {
42 Self(ApiError::internal_error(message))
43 }
44
45 pub fn into_inner(self) -> ApiError {
46 self.0
47 }
48}
49
50impl From<ApiError> for ApiHttpError {
51 fn from(error: ApiError) -> Self {
52 Self(error)
53 }
54}
55
56impl IntoResponse for ApiHttpError {
57 fn into_response(self) -> Response {
58 self.0.into_response()
59 }
60}