configureScope method

FutureOr<void> configureScope(
  1. ScopeCallback callback
)

Configures the scope through the callback.

Implementation

FutureOr<void> configureScope(ScopeCallback callback) async {
  if (!_isEnabled) {
    _options.logger(
      SentryLevel.warning,
      "Instance is disabled and this 'configureScope' call is a no-op.",
    );
  } else {
    final item = _peek();

    try {
      final result = callback(item.scope);
      if (result is Future) {
        await result;
      }
    } catch (err) {
      _options.logger(
        SentryLevel.error,
        "Error in the 'configureScope' callback, error: $err",
      );
      if (_options.automatedTestMode) {
        rethrow;
      }
    }
  }
}