readJSError method

  1. @override
VoltronMap readJSError()
override

Implementation

@override
VoltronMap readJSError() {
  String message = '';
  String stack = '';
  String errorType = '';

  var done = false;
  while (!done) {
    var tag = readErrorTag();
    if (tag == ErrorTag.kUnknownTag) {
      break;
    }
    if (tag == ErrorTag.kEvalError) {
      errorType = "EvalError";
      break;
    } else if (tag == ErrorTag.kRangeError) {
      errorType = "RangeError";
      break;
    } else if (tag == ErrorTag.kReferenceError) {
      errorType = "ReferenceError";
      break;
    } else if (tag == ErrorTag.kSyntaxError) {
      errorType = "SyntaxError";
      break;
    } else if (tag == ErrorTag.kTypeError) {
      errorType = "TypeError";
      break;
    } else if (tag == ErrorTag.kURIError) {
      errorType = "URIError";
      break;
    } else if (tag == ErrorTag.kMessage) {
      message = readString(StringLocation.errorMessage, null);
      break;
    } else if (tag == ErrorTag.kStack) {
      stack = readString(StringLocation.errorStack, null);
      break;
    } else {
      if (tag != ErrorTag.kEnd) {
        throw AssertionError("ErrorTag: $tag");
      }
      done = true;
      break;
    }
  }

  var error = VoltronMap();
  error.push("message", message);
  error.push("stack", stack);
  error.push("type", errorType);
  assignId(error);
  return error;
}