Trace.parse constructor

  1. String trace

Parses a string representation of a stack trace.

trace should be formatted in the same way as a Dart VM or browser stack trace. If it's formatted as a stack chain, this will return the equivalent of Chain.toTrace.


factory Trace.parse(String trace) {
  try {
    if (trace.isEmpty) return Trace(<Frame>[]);
    if (trace.contains(_v8Trace)) return Trace.parseV8(trace);
    if (trace.contains('\tat ')) return Trace.parseJSCore(trace);
    if (trace.contains(_firefoxSafariTrace) ||
        trace.contains(_firefoxEvalTrace)) {
      return Trace.parseFirefox(trace);
    if (trace.contains(chainGap)) return Chain.parse(trace).toTrace();
    if (trace.contains(_friendlyTrace)) {
      return Trace.parseFriendly(trace);

    // Default to parsing the stack trace as a VM trace. This is also hit on
    // IE and Safari, where the stack trace is just an empty string (issue
    // 11257).
    return Trace.parseVM(trace);
  } on FormatException catch (error) {
    throw FormatException('${error.message}\nStack trace:\n$trace');