addBreakpoint method

Future<VMBreakpoint> addBreakpoint (
  1. dynamic uri,
  2. int line,
  3. {int column}
)

Adds a breakpoint at line (and optionally column) in the script with the given canonical uri.

Both line and column are 1-based. The uri may be a String or a Uri.

Implementation

Future<VMBreakpoint> addBreakpoint(uri, int line, {int column}) async {
  if (uri is! String && uri is! Uri) {
    throw new ArgumentError("Invalid uri '$uri', must be a Uri or a String.");
  }

  var params = {"scriptUri": uri.toString(), "line": line};
  if (column != null) params["column"] = column;

  try {
    var response =
        await _scope.sendRequest("addBreakpointWithScriptUri", params);
    return newVMBreakpoint(_scope, response);
  } on rpc.RpcException catch (error) {
    // Error 102 indicates that the breakpoint couldn't be created.
    if (error.code == 102) return null;
    rethrow;
  }
}