loggingScope<S> method

Future<S> loggingScope<S>(
  1. FutureOr<S> process(
    1. LoggingErrNotifier<T>
    )
)

Executes the provided function process with an object of LoggingErrNotifier passed to it.

The object can be used to call LoggingErrNotifier.set() and LoggingErrNotifier.log(), but unlike ErrNotifier.set(), LoggingErrNotifier.set() does not trigger the error handlers, It only updates the value of ErrNotifier.lastError, and triggers the logger and added listener functions.

This is useful when you want the errors set by set() inside process to be only logged without being handled by the error handlers.

Implementation

Future<S> loggingScope<S>(
  FutureOr<S> Function(LoggingErrNotifier<T>) process,
) async {
  assert(_debugAssertNotDisposed());

  final newNotifier = LoggingNotifier.from(_notifier);
  final result = await process(newNotifier);
  newNotifier.dispose();

  return result;
}