-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release/0.11' into main
- Loading branch information
Showing
12 changed files
with
157 additions
and
59 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
49 changes: 49 additions & 0 deletions
49
src/main/java/dev/bannmann/restflow/InvalidResponseException.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,49 @@ | ||
package dev.bannmann.restflow; | ||
|
||
import java.net.http.HttpRequest; | ||
import java.net.http.HttpResponse; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import lombok.Getter; | ||
|
||
/** | ||
* Thrown when the response is invalid. Refer to subclasses for specific cases. | ||
*/ | ||
@Getter | ||
public abstract class InvalidResponseException extends RequestException | ||
{ | ||
private final transient HttpResponse<?> response; | ||
|
||
protected InvalidResponseException( | ||
String message, | ||
Throwable cause, | ||
HttpResponse<?> response, | ||
Map<String, Object> diagnosticsData, | ||
List<StackWalker.StackFrame> callerFrames) | ||
{ | ||
super(message, cause, diagnosticsData, callerFrames); | ||
this.response = response; | ||
} | ||
|
||
@Override | ||
public HttpRequest getRequest() | ||
{ | ||
return response.request(); | ||
} | ||
|
||
public int getStatusCode() | ||
{ | ||
return response.statusCode(); | ||
} | ||
|
||
public String getRawBody() | ||
{ | ||
Object body = response.body(); | ||
if (body == null) | ||
{ | ||
return null; | ||
} | ||
return body.toString(); | ||
} | ||
} |
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
40 changes: 0 additions & 40 deletions
40
src/main/java/dev/bannmann/restflow/RequestStatusException.java
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
src/main/java/dev/bannmann/restflow/ResponseBodyException.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,24 @@ | ||
package dev.bannmann.restflow; | ||
|
||
import java.net.http.HttpResponse; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import lombok.Builder; | ||
|
||
/** | ||
* Thrown when the response body could not be processed. | ||
*/ | ||
public class ResponseBodyException extends InvalidResponseException | ||
{ | ||
@Builder | ||
public ResponseBodyException( | ||
String message, | ||
Throwable cause, | ||
HttpResponse<?> response, | ||
Map<String, Object> diagnosticsData, | ||
List<StackWalker.StackFrame> callerFrames) | ||
{ | ||
super(message, cause, response, diagnosticsData, callerFrames); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/dev/bannmann/restflow/ResponseStatusException.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,24 @@ | ||
package dev.bannmann.restflow; | ||
|
||
import java.net.http.HttpResponse; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import lombok.Builder; | ||
|
||
/** | ||
* Thrown when the response to a request has a non-2xx status code. | ||
*/ | ||
public class ResponseStatusException extends InvalidResponseException | ||
{ | ||
@Builder | ||
public ResponseStatusException( | ||
String message, | ||
Throwable cause, | ||
HttpResponse<?> response, | ||
Map<String, Object> diagnosticsData, | ||
List<StackWalker.StackFrame> callerFrames) | ||
{ | ||
super(message, cause, response, diagnosticsData, callerFrames); | ||
} | ||
} |
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