guardRead<T> function
Runs a read, reporting any failure that isn't already a
LocalDataSourceException as a DataSourceReadException with message.
Implementation
Future<T> guardRead<T>(String message, Future<T> Function() action) async {
try {
return await action();
} catch (error, stackTrace) {
if (error is LocalDataSourceException) rethrow;
Error.throwWithStackTrace(
DataSourceReadException(message, error),
stackTrace,
);
}
}