SBException.fromError constructor

SBException.fromError(
  1. Object error,
  2. StackTrace stackTrace, {
  3. String? context,
})

Implementation

factory SBException.fromError(Object error, StackTrace stackTrace, {String? context}) {
  final stackTraceString = stackTrace.toString();
  final parsed = StackTraceParser.parse(stackTraceString);
  final symbols = stackTraceString.split('\n').where((l) => l.isNotEmpty).toList();
  final reason = context != null ? '$context: $error' : error.toString();

  return SBException(
    error.runtimeType.toString(),
    reason,
    stackTrace: (parsed != null && parsed.isNotEmpty) ? parsed : null,
    callStackSymbols: (parsed == null || parsed.isEmpty) ? symbols : null,
  );
}