simplified error handler
This commit is contained in:
parent
77f62396e0
commit
7728498bf9
1 changed files with 1 additions and 15 deletions
|
|
@ -24,21 +24,7 @@ class ErrorHandler {
|
|||
onError?.call(error, stackTrace);
|
||||
}
|
||||
|
||||
/// Convenience method to wrap code that might throw exceptions
|
||||
T handleError<T>(T Function() operation, {T? defaultValue}) {
|
||||
try {
|
||||
return operation();
|
||||
} catch (error, stackTrace) {
|
||||
notify(error, stackTrace);
|
||||
|
||||
if (defaultValue != null) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Global instance of ErrorHandler for easy access
|
||||
final ErrorHandler errorHandler = ErrorHandler();
|
||||
final ErrorHandler errorHandler = ErrorHandler();
|
||||
|
|
|
|||
Loading…
Reference in a new issue