Skip to content
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

try/catch in a pipe #230

Closed
fintara opened this issue Feb 10, 2019 · 2 comments
Closed

try/catch in a pipe #230

fintara opened this issue Feb 10, 2019 · 2 comments

Comments

@fintara
Copy link
Contributor

fintara commented Feb 10, 2019

I can't seem to find a way to catch exceptions in a pipe.
For example, if I make an HTTP request (in action or map) and it fails, there is no way to catch it and provide an alternative flow.

I think in Cerebral you could pass a map with success/error keys for the two flows. Maybe something similar could be added here as well?

@christianalfoni
Copy link
Member

Hi @fintara ,

We will implement more operators very soon. The op-op spec written for Overmind operators supports error handling as well.

So either:

tryMap(..., {
  resolved:,
  rejected:
})
``

But also:

```js
pipe(
  action(...),
  catchError(...), // only runs if previous operator throws error
  action(...),
)

I think we probably need both, cause there are different situations where you might want one over the other. But yes, this is in "the pipe" (no pun intended) :)

@christianalfoni
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants