mirror of
https://github.com/FoggedLens/deflock-app.git
synced 2026-02-12 16:52:51 +00:00
Address PR review: truncate error response logs and close http client
- Gate full error response body logging behind kDebugMode; truncate to 500 chars in release builds to avoid log noise and data exposure - Add RoutingService.close() and call from NavigationState.dispose() Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -30,7 +30,9 @@ class RoutingService {
|
||||
final http.Client _client;
|
||||
|
||||
RoutingService({http.Client? client}) : _client = client ?? http.Client();
|
||||
|
||||
|
||||
void close() => _client.close();
|
||||
|
||||
// Calculate route between two points using alprwatch
|
||||
Future<RouteResult> calculateRoute({
|
||||
required LatLng start,
|
||||
@@ -80,7 +82,16 @@ class RoutingService {
|
||||
).timeout(kNavigationRoutingTimeout);
|
||||
|
||||
if (response.statusCode != 200) {
|
||||
debugPrint('[RoutingService] Error response body: ${response.body}');
|
||||
if (kDebugMode) {
|
||||
debugPrint('[RoutingService] Error response body: ${response.body}');
|
||||
} else {
|
||||
const maxLen = 500;
|
||||
final body = response.body;
|
||||
final truncated = body.length > maxLen
|
||||
? '${body.substring(0, maxLen)}… [truncated]'
|
||||
: body;
|
||||
debugPrint('[RoutingService] Error response body ($maxLen char max): $truncated');
|
||||
}
|
||||
throw RoutingException('HTTP ${response.statusCode}: ${response.reasonPhrase}');
|
||||
}
|
||||
|
||||
|
||||
@@ -376,4 +376,10 @@ class NavigationState extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_routingService.close();
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user