Package io.dapr.internal.exceptions
Class DaprHttpException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.util.concurrent.ExecutionException
io.dapr.internal.exceptions.DaprHttpException
- All Implemented Interfaces:
Serializable
Internal exception for propagating HTTP status code.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDaprHttpException(int statusCode, byte[] payload) Instantiates a new DaprHttpException with a given HTTP payload. -
Method Summary
Modifier and TypeMethodDescriptionstatic ExecutionExceptionfromGrpcExecutionException(io.grpc.Metadata grpcMetadata, Throwable cause) Creates an ExecutionException (can also be HttpException, if applicable).byte[]Returns the HTTP payload for the exception.intReturns the HTTP Status code for the exception.static booleanisSuccessfulHttpStatusCode(int statusCode) static booleanisValidHttpStatusCode(int statusCode) static intparseHttpStatusCode(String value) Parses a given string value into an HTTP status code, 0 if invalid.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
DaprHttpException
public DaprHttpException(int statusCode, byte[] payload) Instantiates a new DaprHttpException with a given HTTP payload.- Parameters:
statusCode- HTTP status code.payload- HTTP payload.
-
-
Method Details
-
fromGrpcExecutionException
public static ExecutionException fromGrpcExecutionException(io.grpc.Metadata grpcMetadata, Throwable cause) Creates an ExecutionException (can also be HttpException, if applicable).- Parameters:
grpcMetadata- Optional gRPC metadata.cause- Exception triggered during execution.- Returns:
- ExecutionException
-
isValidHttpStatusCode
public static boolean isValidHttpStatusCode(int statusCode) -
isSuccessfulHttpStatusCode
public static boolean isSuccessfulHttpStatusCode(int statusCode) -
parseHttpStatusCode
Parses a given string value into an HTTP status code, 0 if invalid.- Parameters:
value- String value to be parsed.- Returns:
- HTTP status code, 0 if not valid.
-
getStatusCode
public int getStatusCode()Returns the HTTP Status code for the exception.- Returns:
- HTTP Status code for the exception, 0 if not applicable.
-
getPayload
public byte[] getPayload()Returns the HTTP payload for the exception.- Returns:
- HTTP payload, null if not present.
-