@@ -63,27 +63,33 @@ Middleware errorHandler() {
63
63
/// Maps HtHttpException subtypes to appropriate HTTP status codes.
64
64
int _mapExceptionToStatusCode (HtHttpException exception) {
65
65
return switch (exception) {
66
+ InvalidInputException () => HttpStatus .badRequest, // 400
67
+ AuthenticationException () => HttpStatus .unauthorized, // 401
66
68
BadRequestException () => HttpStatus .badRequest, // 400
67
69
UnauthorizedException () => HttpStatus .unauthorized, // 401
68
70
ForbiddenException () => HttpStatus .forbidden, // 403
69
71
NotFoundException () => HttpStatus .notFound, // 404
70
72
ServerException () => HttpStatus .internalServerError, // 500
73
+ OperationFailedException () => HttpStatus .internalServerError, // 500
71
74
NetworkException () => HttpStatus .serviceUnavailable, // 503 (or 500)
72
75
UnknownException () => HttpStatus .internalServerError, // 500
73
- _ => HttpStatus .internalServerError,
76
+ _ => HttpStatus .internalServerError, // Default
74
77
};
75
78
}
76
79
77
80
/// Maps HtHttpException subtypes to consistent error code strings.
78
81
String _mapExceptionToCodeString (HtHttpException exception) {
79
82
return switch (exception) {
83
+ InvalidInputException () => 'INVALID_INPUT' ,
84
+ AuthenticationException () => 'AUTHENTICATION_FAILED' ,
80
85
BadRequestException () => 'BAD_REQUEST' ,
81
86
UnauthorizedException () => 'UNAUTHORIZED' ,
82
87
ForbiddenException () => 'FORBIDDEN' ,
83
88
NotFoundException () => 'NOT_FOUND' ,
84
89
ServerException () => 'SERVER_ERROR' ,
90
+ OperationFailedException () => 'OPERATION_FAILED' ,
85
91
NetworkException () => 'NETWORK_ERROR' ,
86
92
UnknownException () => 'UNKNOWN_ERROR' ,
87
- _ => 'UNKNOWN_ERROR' ,
93
+ _ => 'UNKNOWN_ERROR' , // Default
88
94
};
89
95
}
0 commit comments