Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
org.dartlang.vm.service.element.RPCError Class Reference
Inheritance diagram for org.dartlang.vm.service.element.RPCError:
org.dartlang.vm.service.element.Element

Public Member Functions

 RPCError (JsonObject json)
 
int getCode ()
 
String getDetails ()
 
String getMessage ()
 
JsonObject getRequest ()
 
- Public Member Functions inherited from org.dartlang.vm.service.element.Element
 Element (JsonObject json)
 
JsonObject getJson ()
 

Static Public Member Functions

static RPCError unexpected (String expectedType, Response response)
 

Static Public Attributes

static final int UNEXPECTED_RESPONSE = 5
 

Additional Inherited Members

- Protected Attributes inherited from org.dartlang.vm.service.element.Element
final JsonObject json
 
- Package Functions inherited from org.dartlang.vm.service.element.Element
String getAsString (String name)
 
int getAsInt (String name)
 
boolean getAsBoolean (String name)
 
List< Integer > getListInt (String memberName)
 
List< String > getListString (String memberName)
 
List< List< Integer > > getListListInt (String memberName)
 

Detailed Description

When an RPC encounters an error, it is provided in the error property of the response object. JSON-RPC errors always provide code, message, and data properties.
Here is an example error response for our streamListen request above. This error would be generated if we were attempting to subscribe to the GC stream multiple times from the same client.

{
  "jsonrpc": "2.0",
  "error": {
    "code": 103,
    "message": "Stream already subscribed",
    "data": {
      "details": "The stream 'GC' is already subscribed"
    }
  }
  "id": "2"
}

<p<blockquote>‍

In addition the error codes specified in the JSON-RPC spec, we use the following application specific error codes:

code | message | meaning
---- | ------- | -------
100 | Feature is disabled | The operation is unable to complete because a feature is disabled
101 | VM must be paused | This operation is only valid when the VM is paused
102 | Cannot add breakpoint | The VM is unable to add a breakpoint at the specified line or function
103 | Stream already subscribed | The client is already subscribed to the specified _streamId_
104 | Stream not subscribed | The client is not subscribed to the specified _streamId_

Definition at line 54 of file RPCError.java.

Constructor & Destructor Documentation

◆ RPCError()

org.dartlang.vm.service.element.RPCError.RPCError ( JsonObject  json)
inline

Definition at line 77 of file RPCError.java.

77 {
78 super(json);
79 }

Member Function Documentation

◆ getCode()

int org.dartlang.vm.service.element.RPCError.getCode ( )
inline

Definition at line 81 of file RPCError.java.

81 {
82 return json.get("code").getAsInt();
83 }

◆ getDetails()

String org.dartlang.vm.service.element.RPCError.getDetails ( )
inline

Definition at line 85 of file RPCError.java.

85 {
86 JsonElement data = json.get("data");
87 if (data instanceof JsonObject) {
88 JsonElement details = ((JsonObject) data).get("details");
89 if (details != null) {
90 return details.getAsString();
91 }
92 }
93 return null;
94 }
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switches.h:41

◆ getMessage()

String org.dartlang.vm.service.element.RPCError.getMessage ( )
inline

Definition at line 96 of file RPCError.java.

96 {
97 return json.get("message").getAsString();
98 }

◆ getRequest()

JsonObject org.dartlang.vm.service.element.RPCError.getRequest ( )
inline

Definition at line 100 of file RPCError.java.

100 {
101 JsonElement data = json.get("data");
102 if (data instanceof JsonObject) {
103 JsonElement request = ((JsonObject) data).get("request");
104 if (request instanceof JsonObject) {
105 return (JsonObject) request;
106 }
107 }
108 return null;
109 }

◆ unexpected()

static RPCError org.dartlang.vm.service.element.RPCError.unexpected ( String  expectedType,
Response  response 
)
inlinestatic

Definition at line 62 of file RPCError.java.

62 {
63 String errMsg = "Expected type " + expectedType + " but received " + response.getType();
64 if (response instanceof Sentinel) {
65 errMsg += ": " + ((Sentinel) response).getKind();
66 }
67 JsonObject json = new JsonObject();
68 json.addProperty("code", UNEXPECTED_RESPONSE);
69 json.addProperty("message", errMsg);
70 JsonObject data = new JsonObject();
71 data.addProperty("details", errMsg);
72 data.add("response", response.getJson());
73 json.add("data", data);
74 return new RPCError(json);
75 }

Member Data Documentation

◆ UNEXPECTED_RESPONSE

final int org.dartlang.vm.service.element.RPCError.UNEXPECTED_RESPONSE = 5
static

The response code used by the client when it receives a response from the server that it did not expect. For example, it requested a library element but received a list.

Definition at line 60 of file RPCError.java.


The documentation for this class was generated from the following file: