Skip to content

Commit c58c9a9

Browse files
tommyxchowclaude
andcommitted
guard crashlytics call in error handler for test environments
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5be231d commit c58c9a9

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

lib/apis/base_api_client.dart

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,15 @@ abstract class BaseApiClient {
179179
if (exception is ServerException ||
180180
error.type == DioExceptionType.unknown ||
181181
error.type == DioExceptionType.badCertificate) {
182-
FirebaseCrashlytics.instance.recordError(
183-
exception,
184-
error.stackTrace,
185-
reason: '${error.requestOptions.method} ${error.requestOptions.uri}',
186-
);
182+
try {
183+
FirebaseCrashlytics.instance.recordError(
184+
exception,
185+
error.stackTrace,
186+
reason: '${error.requestOptions.method} ${error.requestOptions.uri}',
187+
);
188+
} catch (_) {
189+
// Firebase may not be initialized (e.g., in tests).
190+
}
187191
}
188192

189193
return exception;

0 commit comments

Comments
 (0)