Skip to content

Commit 02e12cb

Browse files
committed
build(middlewares): update error handling and dependencies
- Update import for ht_shared package - Add default cases to exception handling functions - Add new dependencies for app settings functionality
1 parent 4403d67 commit 02e12cb

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

lib/src/middlewares/error_handler.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import 'dart:io';
55

66
import 'package:dart_frog/dart_frog.dart';
7-
import 'package:ht_http_client/ht_http_client.dart';
7+
import 'package:ht_shared/ht_shared.dart';
88

99
/// Middleware that catches errors and converts them into
1010
/// standardized JSON responses.
@@ -70,6 +70,7 @@ int _mapExceptionToStatusCode(HtHttpException exception) {
7070
ServerException() => HttpStatus.internalServerError, // 500
7171
NetworkException() => HttpStatus.serviceUnavailable, // 503 (or 500)
7272
UnknownException() => HttpStatus.internalServerError, // 500
73+
_ => HttpStatus.internalServerError,
7374
};
7475
}
7576

@@ -81,7 +82,9 @@ String _mapExceptionToCodeString(HtHttpException exception) {
8182
ForbiddenException() => 'FORBIDDEN',
8283
NotFoundException() => 'NOT_FOUND',
8384
ServerException() => 'SERVER_ERROR',
84-
NetworkException() => 'NETWORK_ERROR', // Or 'SERVICE_UNAVAILABLE'
85+
NetworkException() => 'NETWORK_ERROR',
8586
UnknownException() => 'UNKNOWN_ERROR',
87+
_ => 'UNKNOWN_ERROR',
88+
8689
};
8790
}

pubspec.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ dependencies:
1414
# ht_countries_inmemory:
1515
# git:
1616
# url: https://github.com/headlines-toolkit/ht-countries-inmemory.git
17+
ht_app_settings_client:
18+
git:
19+
url: https://github.com/headlines-toolkit/ht-app-settings-client.git
20+
ht_app_settings_inmemory:
21+
git:
22+
url: https://github.com/headlines-toolkit/ht-app-settings-inmemory.git
23+
ht_app_settings_repository:
24+
git:
25+
url: https://github.com/headlines-toolkit/ht-app-settings-repository.git
1726
ht_data_client:
1827
git:
1928
url: https://github.com/headlines-toolkit/ht-data-client.git

0 commit comments

Comments
 (0)