-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5bdd0d5
commit e494355
Showing
12 changed files
with
170 additions
and
51 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
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
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
47 changes: 47 additions & 0 deletions
47
src/main/java/io/github/sashirestela/cleverclient/support/CleverClientException.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 |
---|---|---|
@@ -1,17 +1,64 @@ | ||
package io.github.sashirestela.cleverclient.support; | ||
|
||
import io.github.sashirestela.cleverclient.util.Constant; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
|
||
import java.io.Serializable; | ||
import java.text.MessageFormat; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
public class CleverClientException extends RuntimeException { | ||
|
||
private final HttpResponseInfo responseInfo; | ||
|
||
public CleverClientException(String message) { | ||
super(message); | ||
this.responseInfo = null; | ||
} | ||
|
||
public CleverClientException(Throwable cause) { | ||
super(cause); | ||
this.responseInfo = null; | ||
} | ||
|
||
public CleverClientException(String message, Object... parameters) { | ||
super(MessageFormat.format(message, Arrays.copyOfRange(parameters, 0, parameters.length - 1)), | ||
(Throwable) parameters[parameters.length - 1]); | ||
this.responseInfo = null; | ||
} | ||
|
||
public CleverClientException(HttpResponseInfo responseInfo) { | ||
super(MessageFormat.format(Constant.HTTP_ERROR_MESSAGE, responseInfo.getStatusCode()), null); | ||
this.responseInfo = responseInfo; | ||
} | ||
|
||
public Optional<HttpResponseInfo> responseInfo() { | ||
return Optional.ofNullable(responseInfo); | ||
} | ||
|
||
@Data | ||
@Builder | ||
public static class HttpResponseInfo implements Serializable { | ||
|
||
private int statusCode; | ||
private String data; | ||
private Map<String, List<String>> headers; | ||
private HttpRequestInfo request; | ||
|
||
@Data | ||
@Builder | ||
public static class HttpRequestInfo implements Serializable { | ||
|
||
private String httpMethod; | ||
private String url; | ||
private Map<String, List<String>> headers; | ||
|
||
} | ||
|
||
} | ||
|
||
} |
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