-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
3c69539
commit 4205690
Showing
6 changed files
with
207 additions
and
57 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
54 changes: 54 additions & 0 deletions
54
sdk-common/src/main/java/dev/restate/sdk/client/IngressException.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,54 @@ | ||
// Copyright (c) 2023 - Restate Software, Inc., Restate GmbH | ||
// | ||
// This file is part of the Restate Java SDK, | ||
// which is released under the MIT license. | ||
// | ||
// You can find a copy of the license in file LICENSE in the root | ||
// directory of this repository or package, or at | ||
// https://github.com/restatedev/sdk-java/blob/main/LICENSE | ||
package dev.restate.sdk.client; | ||
|
||
import java.nio.charset.StandardCharsets; | ||
import org.jspecify.annotations.Nullable; | ||
|
||
public class IngressException extends RuntimeException { | ||
|
||
private final int statusCode; | ||
private final byte[] responseBody; | ||
|
||
public IngressException(String message, Throwable cause) { | ||
this(message, -1, null, cause); | ||
} | ||
|
||
public IngressException(String message, int statusCode, byte[] responseBody) { | ||
this(message, statusCode, responseBody, null); | ||
} | ||
|
||
public IngressException(String message, int statusCode, byte[] responseBody, Throwable cause) { | ||
super(message, cause); | ||
this.statusCode = statusCode; | ||
this.responseBody = responseBody; | ||
} | ||
|
||
public int getStatusCode() { | ||
return statusCode; | ||
} | ||
|
||
public byte @Nullable [] getResponseBody() { | ||
return responseBody; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "IngressException{" | ||
+ "statusCode=" | ||
+ statusCode | ||
+ ", responseBody='" | ||
+ new String(responseBody, StandardCharsets.UTF_8) | ||
+ '\'' | ||
+ ", message='" | ||
+ this.getMessage() | ||
+ '\'' | ||
+ '}'; | ||
} | ||
} |