OSDN Git Service

refactor
[bytom/bytom-java-sdk.git] / tx-signer / src / main / java / io / bytom / offline / exception / JSONException.java
1 package io.bytom.offline.exception;\r
2 \r
3 /**\r
4  * JSONException wraps errors due to marshaling/unmarshaling json payloads.\r
5  */\r
6 public class JSONException extends BytomException {\r
7 \r
8     /**\r
9      * Unique indentifier of the request to the server.\r
10      */\r
11     public String requestId;\r
12 \r
13     /**\r
14      * Default constructor.\r
15      */\r
16     public JSONException(String message) {\r
17         super(message);\r
18     }\r
19 \r
20     /**\r
21      * Initializes exception with its message and requestId attributes.\r
22      * Use this constructor in context of an API call.\r
23      *\r
24      * @param message   error message\r
25      * @param requestId unique identifier of the request\r
26      */\r
27     public JSONException(String message, String requestId) {\r
28         super(message);\r
29         this.requestId = requestId;\r
30     }\r
31 \r
32     public String getMessage() {\r
33         String message = "Message: " + super.getMessage();\r
34         if (requestId != null) {\r
35             message += " Request-ID: " + requestId;\r
36         }\r
37         return message;\r
38     }\r
39 }\r