-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from ground-x/release/v1.0.2
[Master] release/v1.0.2 QA Sign-off
- Loading branch information
Showing
13 changed files
with
4,512 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/main/java/xyz/groundx/caver_ext_kas/exception/ExceptionDetail.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package xyz.groundx.caver_ext_kas.exception; | ||
|
||
public class ExceptionDetail { | ||
int code; | ||
String message = ""; | ||
|
||
public ExceptionDetail() { | ||
} | ||
|
||
public int getCode() { | ||
return code; | ||
} | ||
|
||
public String getMessage() { | ||
return message; | ||
} | ||
} |
88 changes: 88 additions & 0 deletions
88
src/main/java/xyz/groundx/caver_ext_kas/exception/KASAPIException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package xyz.groundx.caver_ext_kas.exception; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import xyz.groundx.caver_ext_kas.rest_client.io.swagger.client.ApiException; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class KASAPIException extends RuntimeException { | ||
private int code = 0; | ||
private Map<String, List<String>> responseHeaders = null; | ||
private ExceptionDetail responseBody = null; | ||
|
||
public KASAPIException() {} | ||
|
||
public KASAPIException(Throwable throwable) { | ||
super(throwable); | ||
} | ||
|
||
public KASAPIException(String message) { | ||
super(message); | ||
} | ||
|
||
public KASAPIException(String message, Throwable throwable) { | ||
super(message, throwable); | ||
} | ||
|
||
public KASAPIException(ApiException e) { | ||
this(e.getMessage(), e.getCause(), e.getCode(), e.getResponseHeaders(), e.getResponseBody()); | ||
} | ||
|
||
public KASAPIException(String message, Throwable throwable, int code, Map<String, List<String>> responseHeaders, String responseBody) { | ||
super(message, throwable); | ||
this.code = code; | ||
this.responseHeaders = responseHeaders; | ||
if(responseBody != null && !responseBody.isEmpty()) { | ||
setResponseBody(responseBody); | ||
} | ||
} | ||
|
||
public KASAPIException(String message, int code, Map<String, List<String>> responseHeaders, String responseBody) { | ||
this(message, (Throwable) null, code, responseHeaders, responseBody); | ||
} | ||
|
||
public KASAPIException(String message, Throwable throwable, int code, Map<String, List<String>> responseHeaders) { | ||
this(message, throwable, code, responseHeaders, null); | ||
} | ||
|
||
public KASAPIException(int code, Map<String, List<String>> responseHeaders, String responseBody) { | ||
this((String) null, (Throwable) null, code, responseHeaders, responseBody); | ||
} | ||
|
||
public KASAPIException(int code, String message) { | ||
super(message); | ||
this.code = code; | ||
} | ||
|
||
public KASAPIException(int code, String message, Map<String, List<String>> responseHeaders, String responseBody) { | ||
this(code, message); | ||
this.responseHeaders = responseHeaders; | ||
|
||
if(responseBody != null && !responseBody.isEmpty()) { | ||
setResponseBody(responseBody); | ||
} | ||
} | ||
|
||
public int getCode() { | ||
return code; | ||
} | ||
|
||
public Map<String, List<String>> getResponseHeaders() { | ||
return responseHeaders; | ||
} | ||
|
||
public ExceptionDetail getResponseBody() { | ||
return responseBody; | ||
} | ||
|
||
public void setResponseBody(String responseBody) { | ||
try { | ||
ExceptionDetail detail = new ObjectMapper().readValue(responseBody, ExceptionDetail.class); | ||
this.responseBody = detail; | ||
} catch (IOException e){ | ||
throw new RuntimeException("Failed to parsed json string : " + responseBody); | ||
} | ||
} | ||
} |
Oops, something went wrong.