Frame.parseFriendly constructor

Frame.parseFriendly(
  1. String frame
)

Parses this package's string representation of a stack frame.

Implementation

factory Frame.parseFriendly(String frame) => _catchFormatException(frame, () {
      var match = _friendlyFrame.firstMatch(frame);
      if (match == null) {
        throw FormatException(
            "Couldn't parse package:stack_trace stack trace line '$frame'.");
      }
      // Fake truncated data urls generated by the friendly stack trace format
      // cause Uri.parse to throw an exception so we have to special case
      // them.
      var uri = match[1] == 'data:...'
          ? Uri.dataFromString('')
          : Uri.parse(match[1]!);
      // If there's no scheme, this is a relative URI. We should interpret it
      // as relative to the current working directory.
      if (uri.scheme == '') {
        uri = path.toUri(path.absolute(path.fromUri(uri)));
      }

      var line = match[2] == null ? null : int.parse(match[2]!);
      var column = match[3] == null ? null : int.parse(match[3]!);
      return Frame(uri, line, column, match[4]);
    });