]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/fs-write-stream-atomic/node_modules/iferr/index.coffee
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / node_modules / fs-write-stream-atomic / node_modules / iferr / index.coffee
1 # Delegates to `succ` on sucecss or to `fail` on error
2 # ex: Thing.load 123, iferr cb, (thing) -> ...
3 iferr = (fail, succ) -> (err, a...) ->
4   if err? then fail err
5   else succ? a...
6
7 # Like iferr, but also catches errors thrown from `succ` and passes to `fail`
8 tiferr = (fail, succ) -> iferr fail, (a...) ->
9   try succ a...
10   catch err then fail err
11
12 # Delegate to the success function on success, or throw the error otherwise
13 # ex: Thing.load 123, throwerr (thing) -> ...
14 throwerr = iferr.bind null, (err) -> throw err
15
16 # Prints errors when one is passed, or does nothing otherwise
17 # ex: thing.save printerr
18 printerr = iferr (err) -> console.error err.stack or err
19
20 module.exports = exports = iferr
21 exports.iferr = iferr
22 exports.tiferr = tiferr
23 exports.throwerr = throwerr
24 exports.printerr = printerr