-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow passing
error
when transforming outputs in middleware (#684)
## Summary <!-- Succinctly describe your change, providing context, what you've changed, and why. --> Allows passing an `error` when using `onFunctionRun.transformOutput` in middleware. Runtime code already supports this, allowing for common actions such as recreating (or creating new) errors based on data returned from executions. For example: ```ts new InngestMiddleware({ name: "My Middleware", init() { return { onFunctionRun({ fn }) { return { transformOutput({ result }) { if (result.error && result.error instanceof ForbiddenError) { return { result: { error: new NonRetriableError(result.error.message), }, }; } }, }; }, }; }, }); ``` ## Checklist <!-- Tick these items off as you progress. --> <!-- If an item isn't applicable, ideally please strikeout the item by wrapping it in "~~"" and suffix it with "N/A My reason for skipping this." --> <!-- e.g. "- [ ] ~~Added tests~~ N/A Only touches docs" --> - [ ] ~Added a [docs PR](https://github.com/inngest/website) that references this PR~ N/A Bug fix - [x] Added unit/integration tests - [x] Added changesets if applicable
- Loading branch information
1 parent
2019fe2
commit ae7ea5c
Showing
3 changed files
with
133 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"inngest": patch | ||
--- | ||
|
||
Allow passing `error` when transforming outputs in middleware |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters