How to filter errors in a Bacon.js stream -


sometimes want filter out errors in stream. i'd write this:

stream   .filtererror (error) ->     error.type 'foo' 

but there no filtererror method.

as alternative thought use errors().maperror map errors values, filter them, , map them errors. however, don't see way convert value in stream error.

# filter errors interested in errors = stream.errors()   .maperror (error) ->     error   .filter (error) ->     ...   .mapvaluesbackintoerrors() # ?     

the idea stream in question either carries value or error. both represent domain knowledge; value means system in normal operation , error means have domain error. of domain errors not such want carry them, though, wish filter them out.

the alternative works, of course, , may use combination of map , maperror wrap normal values , errors in style of either type in haskell. instance

stream.map((value) -> { value }).maperror((error) -> { error }) 

now stream output this:

{ value: 1 } { value: 2 } { error: "cannot connect host" } 

on other hand, implementing filtererror wouldn't hard. consider implementing , making pr.


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -