Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • 2
    Although I think many languages today do "background stuff" via async await, and exceptions which occur in the async part are thrown when the async operation is awaited. Commented Feb 13, 2020 at 0:34
  • 1
    Scala has a similar idiom with its Either type being used to represent return values which can either be a normal result or an error. Commented Feb 13, 2020 at 7:13
  • The callback is simply poorly written if it doesn't catch exceptional cases (and either handles them, logs them or wraps them). Even functions which donot throw documented exceptions can throw exceptions at any time if they're dealing with any kind of I/O for example. Commented Feb 15, 2020 at 16:45
  • Ohm, I think you don’t quite understand the problem. If the function throws an exception, who is going to call the callback? Commented Feb 19, 2020 at 16:05
  • @gnasher729 it seems to me that there is not much difference between throwing an exception and returning an error prematurely. If a callback has to happen, any code that can throw or return an error needs to be wrapped. Commented Feb 20, 2020 at 7:20