addErrorInfo method

void addErrorInfo(
  1. String message,
  2. RumErrorSource source, {
  3. StackTrace? stackTrace,
  4. String? errorType,
  5. Map<String, Object?> attributes = const {},
})

Notifies that an error occurred in currently presented View, with the supplied message and with an origin of source. You can optionally supply a stackTrace, errorType, and send additional attributes for this error

Implementation

void addErrorInfo(
  String message,
  RumErrorSource source, {
  StackTrace? stackTrace,
  String? errorType,
  Map<String, Object?> attributes = const {},
}) {
  // If the RUM method channel is somehow disconnected, it will throw a MissingPluginException. If
  // we then proceed to call `addErrorInfo`, it will throw the exception again.
  // We do this here (instead of in `wrap`) so the exception is still bubbled up to Flutter.
  if (message.contains('MissingPluginException') &&
      message.contains('datadog_sdk_flutter')) {
    return;
  }
  wrap('rum.addErrorInfo', logger, attributes, () {
    final currentTime = timeProvider.now();
    return _platform.addErrorInfo(
      currentTime,
      message,
      source,
      stackTrace,
      errorType,
      {DatadogPlatformAttributeKey.errorSourceType: 'flutter', ...attributes},
    );
  });
}