Class GrpcErrorStatusMapping
java.lang.Object
io.superdurable.dex.GrpcErrorStatusMapping
Maps Java Worker application exceptions to gRPC status codes.
Every exception thrown by a Step method or RPC becomes a structured Worker error. By default,
all exceptions use Status.Code.INTERNAL because they originate inside the Worker
application. Applications may override selected exception classes when their operational
semantics require a more specific status. A mapping applies to subclasses unless a closer class
also has a mapping; throwing a gRPC StatusException does not bypass this configuration.
GrpcErrorStatusMapping mapping = GrpcErrorStatusMapping.newBuilder()
.map(PaymentDeclinedException.class, Status.Code.FAILED_PRECONDITION)
.map(WorkerOverloadedException.class, Status.Code.RESOURCE_EXHAUSTED)
.build();
WorkerOptions options = WorkerOptions.newBuilder()
.grpcErrorStatusMapping(mapping)
.build();
The mapping affects the diagnostic status stored with the Worker error. Step retry and failure
policies remain controlled by StepOptions; changing a gRPC status does not itself disable
retries.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilds immutable exception-to-status mappings. -
Method Summary
Modifier and TypeMethodDescriptionCreates a builder whose unmatched exceptions resolve toStatus.Code.INTERNAL.
-
Method Details
-
newBuilder
Creates a builder whose unmatched exceptions resolve toStatus.Code.INTERNAL.- Returns:
- a new mutable builder
-