balena-cli/lib/errors/errors.coffee

19 lines
363 B
CoffeeScript
Raw Normal View History

2014-12-22 16:47:12 +00:00
_ = require('lodash')
log = require('../log/log')
exports.handle = (error, exit = true) ->
return if not error? or error not instanceof Error
if process.env.DEBUG
log.error(error.stack)
else
if error.message?
log.error(error.message)
2015-01-06 16:46:31 +00:00
if _.isNumber(error.exitCode)
errorCode = error.exitCode
2014-12-22 16:47:12 +00:00
else
errorCode = 1
process.exit(errorCode) if exit