guard crashlytics call in error handler for test environments

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Tommy Chow
2026-03-09 20:55:59 -07:00
parent 5be231da73
commit c58c9a9a25

View File

@@ -179,11 +179,15 @@ abstract class BaseApiClient {
if (exception is ServerException ||
error.type == DioExceptionType.unknown ||
error.type == DioExceptionType.badCertificate) {
FirebaseCrashlytics.instance.recordError(
exception,
error.stackTrace,
reason: '${error.requestOptions.method} ${error.requestOptions.uri}',
);
try {
FirebaseCrashlytics.instance.recordError(
exception,
error.stackTrace,
reason: '${error.requestOptions.method} ${error.requestOptions.uri}',
);
} catch (_) {
// Firebase may not be initialized (e.g., in tests).
}
}
return exception;