safeExecute static method
Wraps a function execution with safe error handling
Useful for operations that might throw but shouldn't crash the app.
Implementation
static void safeExecute(
void Function() operation, {
bool silenceStreamErrors = true,
}) {
try {
operation();
} catch (error, stackTrace) {
if (silenceStreamErrors && isStreamClosureError(error)) {
return;
}
NewrelicMobile.instance.recordError(error, stackTrace);
rethrow;
}
}