File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change 1- use anyhow:: anyhow;
1+ use crate :: prelude:: * ;
2+
23use axum:: {
4+ Json ,
35 http:: StatusCode ,
46 response:: { IntoResponse , Response } ,
57} ;
6- use log:: debug;
78use pyo3:: { exceptions:: PyException , prelude:: * } ;
89use std:: {
910 error:: Error ,
1011 fmt:: { Debug , Display } ,
11- sync:: Arc ,
1212} ;
1313
1414#[ derive( Debug ) ]
@@ -38,10 +38,18 @@ impl Error for ApiError {
3838 }
3939}
4040
41+ #[ derive( Serialize ) ]
42+ struct ErrorResponse {
43+ error : String ,
44+ }
45+
4146impl IntoResponse for ApiError {
4247 fn into_response ( self ) -> Response {
4348 debug ! ( "Internal server error:\n {:?}" , self . err) ;
44- ( self . status_code , format ! ( "{:#}" , self . err) ) . into_response ( )
49+ let error_response = ErrorResponse {
50+ error : self . err . to_string ( ) ,
51+ } ;
52+ ( self . status_code , Json ( error_response) ) . into_response ( )
4553 }
4654}
4755
You can’t perform that action at this time.
0 commit comments