isTransientError function
Classifies whether an error is transient (worth retrying) or permanent (fail fast).
Transient errors are network/availability issues that may resolve on retry. Permanent errors are logic/auth issues that require user action or code fixes. Unknown/unrecognized exceptions default to retryable (safe fallback).
Implementation
bool isTransientError(Object error) {
if (error is FirebaseFunctionsException) {
return _isTransientFunctionsCode(error.code);
}
if (error is FirebaseAuthException) {
return _isTransientAuthCode(error.code);
}
if (error is FirebaseException) {
return _isTransientFirebaseCode(error.code);
}
// Network/timeout errors are always transient
if (error is SocketException ||
error is TimeoutException ||
error is HttpException) {
return true;
}
// Programming errors — never retry
if (error is ArgumentError ||
error is FormatException ||
error is StateError) {
return false;
}
// Unknown exceptions default to retryable
return true;
}