Class GrpcErrorStatusMapping

java.lang.Object
io.superdurable.dex.GrpcErrorStatusMapping

public final class GrpcErrorStatusMapping extends Object
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.

  • Method Details

    • newBuilder

      public static GrpcErrorStatusMapping.Builder newBuilder()
      Creates a builder whose unmatched exceptions resolve to Status.Code.INTERNAL.
      Returns:
      a new mutable builder