2525 * </p>
2626 *
2727 * <p>
28- * {@link ClientException} is the class to represent any exception in OSS client side. Generally
29- * ClientException occurs either before sending the request or after receving the response from OSS server side.
30- * For example, if the network is broken when it tries to send a request, then the SDK will throw a {@link ClientException}
31- * instance.
28+ * {@link ClientException} is the class to represent any exception in OSS client
29+ * side. Generally ClientException occurs either before sending the request or
30+ * after receving the response from OSS server side. For example, if the network
31+ * is broken when it tries to send a request, then the SDK will throw a
32+ * {@link ClientException} instance.
3233 * </p>
3334 *
3435 * <p>
35- * {@link ServiceException} is converted from error code from OSS response. For example, when OSS tries to authenticate
36- * a request, if Access ID does not exist, the SDK will throw a {@link ServiceException} or its subclass instance
37- * with the specific error code, which the caller could handle that with specific logic.
36+ * {@link ServiceException} is converted from error code from OSS response. For
37+ * example, when OSS tries to authenticate a request, if Access ID does not
38+ * exist, the SDK will throw a {@link ServiceException} or its subclass instance
39+ * with the specific error code, which the caller could handle that with
40+ * specific logic.
3841 * </p>
3942 *
4043 */
4144public class ClientException extends RuntimeException {
42-
45+
4346 private static final long serialVersionUID = 1870835486798448798L ;
44-
47+
4548 private String errorMessage ;
4649 private String requestId ;
4750 private String errorCode ;
48-
51+
4952 /**
5053 * Creates a default instance.
5154 */
@@ -55,49 +58,66 @@ public ClientException() {
5558
5659 /**
5760 * Creates an instance with error message.
58- * @param errorMessage Error message.
61+ *
62+ * @param errorMessage
63+ * Error message.
5964 */
6065 public ClientException (String errorMessage ) {
6166 this (errorMessage , null );
6267 }
6368
6469 /**
6570 * Creates an instance with an exception
66- * @param cause An exception.
71+ *
72+ * @param cause
73+ * An exception.
6774 */
6875 public ClientException (Throwable cause ) {
6976 this (null , cause );
7077 }
71-
78+
7279 /**
7380 * Creates an instance with error message and an exception.
74- * @param errorMessage Error message.
75- * @param cause An exception.
81+ *
82+ * @param errorMessage
83+ * Error message.
84+ * @param cause
85+ * An exception.
7686 */
7787 public ClientException (String errorMessage , Throwable cause ) {
7888 super (null , cause );
7989 this .errorMessage = errorMessage ;
8090 this .errorCode = ClientErrorCode .UNKNOWN ;
8191 this .requestId = "Unknown" ;
8292 }
83-
93+
8494 /**
8595 * Creates an instance with error message, error code, request Id
86- * @param errorMessage Error message.
87- * @param errorCode Error code, which typically is from a set of predefined errors. The handler code could do action
88- * based on this.
89- * @param requestId Request Id.
96+ *
97+ * @param errorMessage
98+ * Error message.
99+ * @param errorCode
100+ * Error code, which typically is from a set of predefined
101+ * errors. The handler code could do action based on this.
102+ * @param requestId
103+ * Request Id.
90104 */
91105 public ClientException (String errorMessage , String errorCode , String requestId ) {
92106 this (errorMessage , errorCode , requestId , null );
93107 }
94108
95109 /**
96- * Creates an instance with error message, error code, request Id and an exception.
97- * @param errorMessage Error message.
98- * @param errorCode Error code.
99- * @param requestId Request Id.
100- * @param cause An exception.
110+ * Creates an instance with error message, error code, request Id and an
111+ * exception.
112+ *
113+ * @param errorMessage
114+ * Error message.
115+ * @param errorCode
116+ * Error code.
117+ * @param requestId
118+ * Request Id.
119+ * @param cause
120+ * An exception.
101121 */
102122 public ClientException (String errorMessage , String errorCode , String requestId , Throwable cause ) {
103123 this (errorMessage , cause );
@@ -107,14 +127,16 @@ public ClientException(String errorMessage, String errorCode, String requestId,
107127
108128 /**
109129 * Get error message.
130+ *
110131 * @return Error message in string.
111132 */
112133 public String getErrorMessage () {
113134 return errorMessage ;
114135 }
115-
136+
116137 /**
117138 * Get error code.
139+ *
118140 * @return Error code.
119141 */
120142 public String getErrorCode () {
@@ -123,16 +145,16 @@ public String getErrorCode() {
123145
124146 /**
125147 * Gets request id.
148+ *
126149 * @return The request Id.
127150 */
128151 public String getRequestId () {
129- return requestId ;
152+ return requestId ;
130153 }
131154
132155 @ Override
133156 public String getMessage () {
134- return getErrorMessage ()
135- + "\n [ErrorCode]: " + errorCode != null ? errorCode : ""
136- + "\n [RequestId]: " + requestId != null ? requestId : "" ;
157+ return getErrorMessage () + "\n [ErrorCode]: " + errorCode != null ? errorCode
158+ : "" + "\n [RequestId]: " + requestId != null ? requestId : "" ;
137159 }
138160}
0 commit comments