wrap function
void
wrap(
- String methodName,
- InternalLogger logger,
- Map<
String, Object?> ? attributes, - WrappedCall<
void> call,
Wraps a call to a platform channel with common error handling and telemetry.
Implementation
void wrap(
String methodName,
InternalLogger logger,
Map<String, Object?>? attributes,
WrappedCall<void> call,
) {
try {
var result = call();
if (result is Future) {
result.catchError((dynamic e, StackTrace st) {
_handleError(e, st, methodName, logger, attributes);
}, test: _willHandleError);
}
} catch (e, st) {
if (!_handleError(e, st, methodName, logger, attributes)) {
rethrow;
}
}
}