addError method
void
addError(
- Object error,
- RumErrorSource source, {
- StackTrace? stackTrace,
- String? errorType,
- Map<
String, Object?> attributes = const {},
Notifies that the Exception or Error error occurred in currently
presented View, with an origin of source. You can optionally set
additional attributes for this error, an errorType and a
stackTrace
Implementation
void addError(
Object error,
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 `addError`, it will throw the exception again.
// We do this here (instead of in Wrap) so the exception is still bubbled up to Flutter.
if (error is MissingPluginException) {
if (error.message?.contains('datadog_sdk_flutter') ?? false) {
return;
}
}
wrap('rum.addError', logger, attributes, () {
final currentTime = timeProvider.now();
return _platform.addError(
currentTime,
error,
source,
stackTrace,
errorType,
{DatadogPlatformAttributeKey.errorSourceType: 'flutter', ...attributes},
);
});
}