safeUpdateAsyncWithHandler<T> static method
Future<T>
safeUpdateAsyncWithHandler<T>(
- Future<
T> update(), - Future<
T> onError(- Object error,
- StackTrace stackTrace
Execute an async function with custom error handler
Implementation
static Future<T> safeUpdateAsyncWithHandler<T>(
Future<T> Function() update,
Future<T> Function(Object error, StackTrace stackTrace) onError,
) async {
try {
return await update();
} catch (e, stackTrace) {
Logger.error('Async state update error (custom handler)', e);
Logger.debug('Stack trace', stackTrace);
return await onError(e, stackTrace);
}
}