@@ -63,27 +63,33 @@ Middleware errorHandler() {
6363/// Maps HtHttpException subtypes to appropriate HTTP status codes.
6464int _mapExceptionToStatusCode (HtHttpException exception) {
6565 return switch (exception) {
66+ InvalidInputException () => HttpStatus .badRequest, // 400
67+ AuthenticationException () => HttpStatus .unauthorized, // 401
6668 BadRequestException () => HttpStatus .badRequest, // 400
6769 UnauthorizedException () => HttpStatus .unauthorized, // 401
6870 ForbiddenException () => HttpStatus .forbidden, // 403
6971 NotFoundException () => HttpStatus .notFound, // 404
7072 ServerException () => HttpStatus .internalServerError, // 500
73+ OperationFailedException () => HttpStatus .internalServerError, // 500
7174 NetworkException () => HttpStatus .serviceUnavailable, // 503 (or 500)
7275 UnknownException () => HttpStatus .internalServerError, // 500
73- _ => HttpStatus .internalServerError,
76+ _ => HttpStatus .internalServerError, // Default
7477 };
7578}
7679
7780/// Maps HtHttpException subtypes to consistent error code strings.
7881String _mapExceptionToCodeString (HtHttpException exception) {
7982 return switch (exception) {
83+ InvalidInputException () => 'INVALID_INPUT' ,
84+ AuthenticationException () => 'AUTHENTICATION_FAILED' ,
8085 BadRequestException () => 'BAD_REQUEST' ,
8186 UnauthorizedException () => 'UNAUTHORIZED' ,
8287 ForbiddenException () => 'FORBIDDEN' ,
8388 NotFoundException () => 'NOT_FOUND' ,
8489 ServerException () => 'SERVER_ERROR' ,
90+ OperationFailedException () => 'OPERATION_FAILED' ,
8591 NetworkException () => 'NETWORK_ERROR' ,
8692 UnknownException () => 'UNKNOWN_ERROR' ,
87- _ => 'UNKNOWN_ERROR' ,
93+ _ => 'UNKNOWN_ERROR' , // Default
8894 };
8995}
0 commit comments