Bacon provides the Bacon.Error
constructor to explicitly mark events or values of EventStreams or properties respectively as errors so that Bacon can identify them and open up a wide variety of other APIs to work with those errors specifically.
Depending on how we create a stream, Bacon.js can sometimes identify whether an event is a success or error event, and if it's an error event, then it can convert it to Bacon.Error
. For example, if we use Bacon.fromPromise
to create an EventStream, then Bacon can identify an error easily, since when an error occurs in a promise pattern, the second callback of the then()
method or the callback passed to the catch()
method is executed.
In case Bacon cannot identify whether an event is an error or success event while creating a stream, then we need to explicitly create instances of Bacon.Error
and replace the error events with them. For example, when using Bacon.fromCallback
, there is no way for Bacon.js to know whether an event is a...