-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRpcException.java
More file actions
43 lines (30 loc) · 974 Bytes
/
RpcException.java
File metadata and controls
43 lines (30 loc) · 974 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package rpc.exception;
import org.json.JSONObject;
public abstract class RpcException extends Exception {
private static final long serialVersionUID = 1L;
public static final int PARSE_ERROR = -32700;
public static final int INVALID_REQUEST = -32600;
public static final int METHOD_NOT_FOUND = -32601;
public static final int INVALID_PARAMS = -32602;
public static final int INTERNAL_ERROR = -32603;
public static final int AUTHENTIFICATION_ERROR= -32001;
public static final int PERMISSION_DENIED = -32002;
// client error
// user defined error
public RpcException() {
}
public RpcException(String message) {
super(message);
}
abstract public int errorCode();
public String errorData() {
return null;
}
public JSONObject toError() {
JSONObject e = new JSONObject();
e.put("code", errorCode());
e.put("message", this.toString());
e.put("data", errorData());
return e;
}
}