handleFirebaseError function
- dynamic error, {
- String? operation,
Transforms Firebase exceptions into app-specific exceptions
Implementation
RALIException handleFirebaseError(dynamic error, {String? operation}) {
if (error is RALIException) return error;
final context = operation != null ? 'during $operation' : '';
// Handle specific Firebase error codes
if (error != null && error.toString().contains('permission-denied')) {
return RALIException('Permission denied $context', cause: error);
}
if (error != null && error.toString().contains('unavailable')) {
return NetworkException('Network unavailable $context', cause: error);
}
// Generic fallback
return RALIException('Error occurred $context', cause: error);
}