basicErrorHandling function
Implementation
void basicErrorHandling(AuthService authService) async {
try {
await authService.signInWithEmailAndPassword(
email: 'user@example.com',
password: 'password',
);
} on InvalidCredentialsException catch (e) {
// Access all error properties
print('Error Type: ${e.errorType}');
print('Error Code: ${e.code}');
print('Message: ${e.message}');
print('Severity: ${e.severity}');
print('Is Recoverable: ${e.isRecoverable}');
print('Metadata: ${e.metadata}');
print('Original Error: ${e.originalError}');
// Show custom UI based on error type
showCustomErrorDialog('Invalid credentials');
} on NetworkException catch (e) {
// Handle network errors differently
if (e.isNetworkRelated) {
showRetryDialog();
}
} on AuthException catch (e) {
// Catch all other auth exceptions
handleGenericError(e);
}
}