safeWithContext<T> static method
T?
safeWithContext<T>(})
Safe execution with enhanced error context for debugging
Implementation
static T? safeWithContext<T>(
T Function() operation, {
required String component,
required String operationName,
Map<String, dynamic>? additionalContext,
T? fallback,
}) {
try {
ObslyLogger.verbose('🛡️ Executing $component.$operationName');
final result = operation();
ObslyLogger.verbose('✅ $component.$operationName completed successfully');
return result;
} catch (e, stack) {
ObslyLogger.errorWithContext(
component,
operationName,
e.toString(),
stack,
context: additionalContext ?? {},
);
return fallback;
}
}