Skip to content

Commit

Permalink
Add extra data parameter to reportCheckedError
Browse files Browse the repository at this point in the history
  • Loading branch information
ThexXTURBOXx committed Nov 29, 2024
1 parent cac206e commit a104708
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions lib/core/catcher_2.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, dynamic>? extraData,
}) {
dynamic errorValue = error;
dynamic stackTraceValue = stackTrace;
errorValue ??= 'undefined error';
stackTraceValue ??= StackTrace.current;
_instance._reportError(error, stackTrace);
_instance._reportError(errorValue, stackTraceValue, extraData: extraData);
}

Future<void> _reportError(
error,
stackTrace, {
FlutterErrorDetails? errorDetails,
Map<String, dynamic>? extraData,
}) async {
if ((errorDetails?.silent ?? false) && !_currentConfig.handleSilentError) {
_logger.info(
Expand Down Expand Up @@ -549,7 +554,7 @@ class Catcher2 implements ReportModeAction {
DateTime.now(),
_deviceParameters,
_applicationParameters,
_currentConfig.customParameters,
{..._currentConfig.customParameters, ...(extraData ?? {})},
errorDetails,
_getPlatformType(),
screenshot,
Expand Down
2 changes: 1 addition & 1 deletion lib/model/report.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a104708

Please sign in to comment.