mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-23 23:42:24 +00:00
19 lines
363 B
CoffeeScript
19 lines
363 B
CoffeeScript
_ = 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)
|
|
|
|
if _.isNumber(error.exitCode)
|
|
errorCode = error.exitCode
|
|
else
|
|
errorCode = 1
|
|
|
|
process.exit(errorCode) if exit
|