capture method

Future<void> capture(
  1. Object error, [
  2. StackTrace? stack,
  3. Map<String, Object?>? extra
])

Report an error. handled = false marks an uncaught crash.

Implementation

Future<void> capture(
  Object error, [
  StackTrace? stack,
  Map<String, Object?>? extra,
]) {
  final e = Map<String, Object?>.of(extra ?? const {});
  final handled = e.remove('handled') ?? true;
  final level = e.remove('level') ?? 'error';
  return _send(
    type: error.runtimeType.toString(),
    message: error.toString(),
    frames: _parseStack((stack ?? StackTrace.current).toString()),
    handled: handled == true,
    level: level as String,
    context: e,
  );
}