mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-27 14:35:11 +08:00
# Conflicts: # jsowell-ui/.env.development # jsowell-ui/.env.staging # jsowell-ui/bin/build-sit.bat # jsowell-ui/bin/build.bat # jsowell-ui/src/api/adapayMember/adapayMember.js # jsowell-ui/src/api/pile/merchant.js # jsowell-ui/src/router/index.js # jsowell-ui/src/views/financial/financeDetail.vue # jsowell-ui/src/views/financial/merchant.vue # jsowell-ui/src/views/homeIndex/homeIndex.vue # jsowell-ui/src/views/login.vue # jsowell-ui/src/views/pile/basic/detail.vue # jsowell-ui/src/views/pile/station/components/SiteInfo.vue # jsowell-ui/src/views/pile/station/detail.vue # jsowell-ui/src/views/pile/station/orderReport.vue
25 lines
803 B
CoffeeScript
25 lines
803 B
CoffeeScript
# Delegates to `succ` on sucecss or to `fail` on error
|
|
# ex: Thing.load 123, iferr cb, (thing) -> ...
|
|
iferr = (fail, succ) -> (err, a...) ->
|
|
if err? then fail err
|
|
else succ? a...
|
|
|
|
# Like iferr, but also catches errors thrown from `succ` and passes to `fail`
|
|
tiferr = (fail, succ) -> iferr fail, (a...) ->
|
|
try succ a...
|
|
catch err then fail err
|
|
|
|
# Delegate to the success function on success, or throw the error otherwise
|
|
# ex: Thing.load 123, throwerr (thing) -> ...
|
|
throwerr = iferr.bind null, (err) -> throw err
|
|
|
|
# Prints errors when one is passed, or does nothing otherwise
|
|
# ex: thing.save printerr
|
|
printerr = iferr (err) -> console.error err.stack or err
|
|
|
|
module.exports = exports = iferr
|
|
exports.iferr = iferr
|
|
exports.tiferr = tiferr
|
|
exports.throwerr = throwerr
|
|
exports.printerr = printerr
|