You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
asTerminalError to provide an easy mapping between domain model errors and Restate TerminalError (#562)
* TerminalError.cause should not be exposed. This commit deprecates it.
* Add `asTerminalError` to let people map their domain model errors to `TerminalError`
* Wireup + add example
* Error code. This should be an HTTP status code, and in case the service was invoked from the ingress, this will be propagated back to the caller.
99
+
*/
100
+
errorCode?: number;
101
+
/**
102
+
* @deprecated YOU MUST NOT USE THIS FIELD, AS IT WON'T BE RECORDED AND CAN LEAD TO NON-DETERMINISM! From the next SDK version, the constructor won't accept this field anymore.
103
+
*/
104
+
cause?: any;
105
+
}
106
+
){
79
107
super(message,options);
80
108
}
81
109
}
82
110
111
+
/**
112
+
* Returned by `RestatePromise.withTimeout` when the timeout is reached.
113
+
*/
83
114
exportclassTimeoutErrorextendsTerminalError{
84
115
publicname="TimeoutError";
85
116
@@ -88,6 +119,9 @@ export class TimeoutError extends TerminalError {
thrownewTerminalError(`Failed to deserialize input.`,{
471
+
consterror=ensureError(e);
472
+
thrownewTerminalError(`Failed to deserialize input: ${error.message}`,{
471
473
errorCode: 400,
472
-
cause: e,
473
474
});
474
475
}
475
476
constres: unknown=awaitthis.handler(context,req);
@@ -818,6 +819,43 @@ export type ServiceOptions = {
818
819
* otherwise the service discovery will fail.
819
820
*/
820
821
ingressPrivate?: boolean;
822
+
823
+
/**
824
+
* By default, Restate will consider any error terminal, that is non retryable, if it's an instance of `TerminalError`.
825
+
*
826
+
* By setting this field, you can provide a function to map specific errors in your domain to `TerminalError` (or undefined, if the error should be considered retryable). Once `TerminalError`, these errors won't be retried.
827
+
*
828
+
* Note: this will be used both for errors thrown by `ctx.run` closures and by errors thrown in restate handlers.
0 commit comments