-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support try-catch for both invoke
and run
#65
Conversation
24fa4a9
to
d36545d
Compare
bae2982
to
8330bc0
Compare
If an exception is thrown in the `invoke` or `run` function, it will now be caught and returned as a `StepError` exception. This will allow the error to be propagated to the caller and handled appropriately. Transforming the errors into a `StepError` exception is following the Inngest SDK spec: https://github.com/inngest/inngest/blob/main/docs/SDK_SPEC.md#522-memoizing-a-step Inngest JS SDK behavior: https://github.com/inngest/inngest-js/blob/4f91d9c302592ecc2228914469dd057ae148005b/packages/inngest/src/components/execution/v1.ts#L437-L443 Inngest documentation: https://www.inngest.com/docs/features/inngest-functions/error-retries/inngest-errors#step-errors
8330bc0
to
178e8e2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, let's double check whether avoiding checked exceptions is desired and iterate post merge if necessary
ResultStatusCode.StepComplete, | ||
ResultStatusCode.StepError, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wonder if it's worth pulling out this set as a constant, maybe calling it something like "terminal" status codes? Fine to leave as is if other SDKs aren't doing that
is RetryAfterError, | ||
is NonRetriableError, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar comment as the set of ResultStatusCode
s, but again not worth doing if other SDKs aren't
@BeforeAll | ||
static void setup(@Autowired CommHandler handler) { | ||
handler.register("http://localhost:8080"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can remove this now that #67 is merged right?
Summary
If an exception is thrown in the
invoke
orrun
function, it will nowbe caught and returned as a
StepError
exception. This will allow theerror to be propagated to the caller and handled appropriately.
Transforming the errors into a
StepError
exception is following theSDK spec:
https://github.com/inngest/inngest/blob/main/docs/SDK_SPEC.md#522-memoizing-a-step
JS SDK behavior:
https://github.com/inngest/inngest-js/blob/4f91d9c302592ecc2228914469dd057ae148005b/packages/inngest/src/components/execution/v1.ts#L437-L443
Docs:
https://www.inngest.com/docs/features/inngest-functions/error-retries/inngest-errors#step-errors
StepError
is aRuntimeException
which means that it can be used in Java code without needing to change the interface ofInngest.execute
to introduce checked exceptions or break existingstep.run
&step.invoke
calls by requiring strict handling of the exception.Usage
Invoke
Run
Changes:
StepError
exception that users can catch to handler errors.step.run
.step.invoke
.Checklist
Related