11use axum:: {
2- extract:: {
3- multipart:: MultipartRejection ,
4- rejection:: { FormRejection , QueryRejection } ,
5- } ,
2+ extract:: rejection:: QueryRejection ,
63 http:: StatusCode ,
74 response:: { IntoResponse , Response } ,
85} ;
@@ -17,16 +14,8 @@ pub type WithAppRejection<E> = WithRejection<E, AppError>;
1714pub enum AppError {
1815 #[ error( "I couldn't access the database! :(" ) ]
1916 Database ( #[ from] sqlx:: Error ) ,
20- #[ error( "Something weird went wrong :(" ) ]
21- MultipartError ( #[ from] axum:: extract:: multipart:: MultipartError ) ,
2217 #[ error( "I couldn't find the page you're looking for! :(" ) ]
2318 NotFound ,
24- #[ error( "Please fill out all the fields!" ) ]
25- Form ( #[ from] FormRejection ) ,
26- #[ error( "Something weird went wrong :(" ) ]
27- MultipartRejection ( #[ from] MultipartRejection ) ,
28- #[ error( "Please change the following fields :3\n {0}" ) ]
29- ValidateForm ( #[ from] axum_valid:: ValidRejection < FormRejection > ) ,
3019 #[ error( "Please change the following fields :3\n {0}" ) ]
3120 ValidateQuery ( #[ from] axum_valid:: ValidRejection < QueryRejection > ) ,
3221}
@@ -36,11 +25,7 @@ impl AppError {
3625 match self {
3726 AppError :: Database ( _) => StatusCode :: SERVICE_UNAVAILABLE ,
3827 AppError :: NotFound => StatusCode :: NOT_FOUND ,
39- AppError :: Form ( _)
40- | AppError :: MultipartError ( _)
41- | AppError :: MultipartRejection ( _)
42- | AppError :: ValidateForm ( _)
43- | AppError :: ValidateQuery ( _) => StatusCode :: BAD_REQUEST ,
28+ AppError :: ValidateQuery ( _) => StatusCode :: BAD_REQUEST ,
4429 }
4530 }
4631}
0 commit comments