question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Handling uncaught exceptions

See original GitHub issue

So I am working on a project where there are many sagas and sometimes they result in errors. In development the errors get logged to the console (which is quite nice), but in production I’d like to be able to capture the exception and send it to an error monitoring service (such as honeybadger or getsentry), is there a way to do this?

The only thing I can think of is instead of passing many sagas to createSagaMiddleware to only pass a single root saga and to manually capture the error in the root saga after forking every other saga. Is there another approach that I could use?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

11reactions
yelouaficommented, Apr 9, 2016

@axelson For forked sagas you can use the done property to catch errors

function* wrap(saga, ...args) {
  const task = yield fork(saga, ...args)
  task.done.catch(reportTheError) // handle the error
  return task
} 

// wrap the fork effect
const wrapFork = (saga, ...args) => call(wrap, saga, ...args)

// then use it instead of fork
function* mySaga() {
  while(true) {
    const action = take(ACTION)
    yield wrapFork(doSomething, action)
  }
}

you can do the same thing with called sagas by putting the call in a try/catch then rethrow the error.

0reactions
tommedemacommented, Sep 22, 2016

@ronanwize re “we actually decided to push that down a layer so anything running in a saga will return an error object we can test for”: how did you create a lower level layer in which you can catch all sagas’ exceptions?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How uncaught exceptions are handled in Java - Javamex
Java actually handles uncaught exceptions according to the thread in which they occur. When an uncaught exception occurs in a particular thread, Java...
Read more >
android - Need to handle uncaught exception and send log file
Handle uncaughtException in your Application subclass. · After catching an exception, start a new activity to ask the user to send a log....
Read more >
20.4 — Uncaught exceptions and catch-all handlers - Learn C++
If your program uses exceptions, consider using a catch-all handler in main, to help ensure orderly behavior when an unhandled exception occurs.
Read more >
Uncaught Exceptions in Java - BTech Smart Class
The uncaught exceptions are the exceptions that are not caught by the compiler but automatically caught and handled by the Java built-in exception...
Read more >
Handling of Uncaught Exceptions in Haskell - Serokell
Handling of Uncaught Exceptions in Haskell ... When your Haskell application's thread throws an exception that does not get caught, the Haskell ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found