From a10470810fecac5527d5f6d3b181cce4210a3f43 Mon Sep 17 00:00:00 2001 From: Nico Mexis Date: Fri, 29 Nov 2024 15:35:20 +0100 Subject: [PATCH] Add extra data parameter to reportCheckedError --- lib/core/catcher_2.dart | 11 ++++++++--- lib/model/report.dart | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/core/catcher_2.dart b/lib/core/catcher_2.dart index 3c3be98..54939fb 100644 --- a/lib/core/catcher_2.dart +++ b/lib/core/catcher_2.dart @@ -509,18 +509,23 @@ class Catcher2 implements ReportModeAction { /// Report checked error (error caught in try-catch block). Catcher 2 will /// treat this as normal exception and pass it to handlers. - static void reportCheckedError(error, stackTrace) { + static void reportCheckedError( + error, + stackTrace, { + Map? extraData, + }) { dynamic errorValue = error; dynamic stackTraceValue = stackTrace; errorValue ??= 'undefined error'; stackTraceValue ??= StackTrace.current; - _instance._reportError(error, stackTrace); + _instance._reportError(errorValue, stackTraceValue, extraData: extraData); } Future _reportError( error, stackTrace, { FlutterErrorDetails? errorDetails, + Map? extraData, }) async { if ((errorDetails?.silent ?? false) && !_currentConfig.handleSilentError) { _logger.info( @@ -549,7 +554,7 @@ class Catcher2 implements ReportModeAction { DateTime.now(), _deviceParameters, _applicationParameters, - _currentConfig.customParameters, + {..._currentConfig.customParameters, ...(extraData ?? {})}, errorDetails, _getPlatformType(), screenshot, diff --git a/lib/model/report.dart b/lib/model/report.dart index 6e00823..2684777 100644 --- a/lib/model/report.dart +++ b/lib/model/report.dart @@ -41,7 +41,7 @@ class Report { final PlatformType platformType; /// Screenshot of screen where error happens. Screenshot won't work everywhere - /// (i.e. web platform), so this may be null. + /// (i.e. web platform), so this may be `null` final XFile? screenshot; /// Creates json from current instance