catchError method

void catchError(
  1. Object? ex, {
  2. StackTrace? stack,
  3. String? library,
  4. DiagnosticsNode? context,
  5. IterableFilter<String>? stackFilter,
  6. InformationCollector? informationCollector,
  7. bool? silent,
})

Catch and explicitly handle the error.

Implementation

void catchError(
  Object? ex, {
  StackTrace? stack,
  String? library,
  DiagnosticsNode? context,
  IterableFilter<String>? stackFilter,
  InformationCollector? informationCollector,
  bool? silent,
}) {
  if (ex is! Exception) {
    ex = Exception(ex.toString());
  }

  appState?.catchError(
    ex,
    stack: stack,
    // Supply the app's name instead.
    library: library ?? App.packageInfo?.appName,
    context: context,
    stackFilter: stackFilter,
    informationCollector: informationCollector,
    silent: silent ?? false,
  );
}