3
3
4
4
import 'dart:io' ;
5
5
6
+ import 'package:core/core.dart' ;
6
7
import 'package:dart_frog/dart_frog.dart' ;
7
- import 'package:ht_api/src/config/environment_config.dart' ;
8
- import 'package:ht_shared/ht_shared.dart' ;
8
+ import 'package:flutter_news_app_api_server_full_source_code/src/config/environment_config.dart' ;
9
9
import 'package:json_annotation/json_annotation.dart' ;
10
10
import 'package:logging/logging.dart' ;
11
11
@@ -20,10 +20,10 @@ Middleware errorHandler() {
20
20
// Attempt to execute the request handler
21
21
final response = await handler (context);
22
22
return response;
23
- } on HtHttpException catch (e, stackTrace) {
24
- // Handle specific HtHttpExceptions from the client/repository layers
23
+ } on HttpException catch (e, stackTrace) {
24
+ // Handle specific HttpExceptions from the client/repository layers
25
25
final statusCode = _mapExceptionToStatusCode (e);
26
- _log.warning ('HtHttpException Caught' , e, stackTrace);
26
+ _log.warning ('HttpException Caught' , e, stackTrace);
27
27
return _jsonErrorResponse (
28
28
statusCode: statusCode,
29
29
exception: e,
@@ -64,8 +64,8 @@ Middleware errorHandler() {
64
64
};
65
65
}
66
66
67
- /// Maps HtHttpException subtypes to appropriate HTTP status codes.
68
- int _mapExceptionToStatusCode (HtHttpException exception) {
67
+ /// Maps HttpException subtypes to appropriate HTTP status codes.
68
+ int _mapExceptionToStatusCode (HttpException exception) {
69
69
return switch (exception) {
70
70
InvalidInputException () => HttpStatus .badRequest, // 400
71
71
AuthenticationException () => HttpStatus .unauthorized, // 401
@@ -82,8 +82,8 @@ int _mapExceptionToStatusCode(HtHttpException exception) {
82
82
};
83
83
}
84
84
85
- /// Maps HtHttpException subtypes to consistent error code strings.
86
- String _mapExceptionToCodeString (HtHttpException exception) {
85
+ /// Maps HttpException subtypes to consistent error code strings.
86
+ String _mapExceptionToCodeString (HttpException exception) {
87
87
return switch (exception) {
88
88
InvalidInputException () => 'invalidInput' ,
89
89
AuthenticationException () => 'authenticationFailed' ,
@@ -107,7 +107,7 @@ String _mapExceptionToCodeString(HtHttpException exception) {
107
107
/// application to read the error message body.
108
108
Response _jsonErrorResponse ({
109
109
required int statusCode,
110
- required HtHttpException exception,
110
+ required HttpException exception,
111
111
required RequestContext context,
112
112
}) {
113
113
final errorCode = _mapExceptionToCodeString (exception);
0 commit comments