mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-02-25 19:11:51 +00:00
Rename error code to error exit code
This commit is contained in:
parent
ac00a96728
commit
e9caca8c24
lib
@ -47,9 +47,9 @@ exports.add = permissions.user (params) ->
|
|||||||
# and accomodate as most as possible to prevent
|
# and accomodate as most as possible to prevent
|
||||||
# this types of checks in client code.
|
# this types of checks in client code.
|
||||||
if error.code is 'EISDIR'
|
if error.code is 'EISDIR'
|
||||||
error.message = "File is a directory: #{params.path}"
|
error.message = "File is a directory: #{error.path}"
|
||||||
|
|
||||||
if error.code is 'ENOENT'
|
if error.code is 'ENOENT'
|
||||||
error = new Error("File not found: #{params.path}")
|
error = new Error("File not found: #{error.path}")
|
||||||
|
|
||||||
errors.handle(error)
|
errors.handle(error)
|
||||||
|
@ -10,8 +10,8 @@ exports.handle = (error, exit = true) ->
|
|||||||
if error.message?
|
if error.message?
|
||||||
log.error(error.message)
|
log.error(error.message)
|
||||||
|
|
||||||
if _.isNumber(error.code)
|
if _.isNumber(error.exitCode)
|
||||||
errorCode = error.code
|
errorCode = error.exitCode
|
||||||
else
|
else
|
||||||
errorCode = 1
|
errorCode = 1
|
||||||
|
|
||||||
|
@ -48,9 +48,9 @@ describe 'Errors:', ->
|
|||||||
checkProcessExitOption error, false, (processExitStub) ->
|
checkProcessExitOption error, false, (processExitStub) ->
|
||||||
expect(processExitStub).to.not.have.been.called
|
expect(processExitStub).to.not.have.been.called
|
||||||
|
|
||||||
it 'should handle a custom error code from the error instance', ->
|
it 'should handle a custom error exit code from the error instance', ->
|
||||||
error = new Error()
|
error = new Error()
|
||||||
error.code = 123
|
error.exitCode = 123
|
||||||
checkProcessExitOption error, true, (processExitStub) ->
|
checkProcessExitOption error, true, (processExitStub) ->
|
||||||
expect(processExitStub).to.have.been.calledWith(123)
|
expect(processExitStub).to.have.been.calledWith(123)
|
||||||
|
|
||||||
|
@ -13,8 +13,8 @@ exports.NotFound = class NotFound extends TypedError
|
|||||||
constructor: (name) ->
|
constructor: (name) ->
|
||||||
@message = "Couldn't find #{name}"
|
@message = "Couldn't find #{name}"
|
||||||
|
|
||||||
# Error code
|
# Error exit code
|
||||||
code: 1
|
exitCode: 1
|
||||||
|
|
||||||
exports.InvalidConfigFile = class InvalidConfigFile extends TypedError
|
exports.InvalidConfigFile = class InvalidConfigFile extends TypedError
|
||||||
|
|
||||||
@ -29,8 +29,8 @@ exports.InvalidConfigFile = class InvalidConfigFile extends TypedError
|
|||||||
constructor: (file) ->
|
constructor: (file) ->
|
||||||
@message = "Invalid configuration file: #{file}"
|
@message = "Invalid configuration file: #{file}"
|
||||||
|
|
||||||
# Error code
|
# Error exit code
|
||||||
code: 1
|
exitCode: 1
|
||||||
|
|
||||||
exports.InvalidCredentials = class InvalidCredentials extends TypedError
|
exports.InvalidCredentials = class InvalidCredentials extends TypedError
|
||||||
|
|
||||||
@ -43,8 +43,8 @@ exports.InvalidCredentials = class InvalidCredentials extends TypedError
|
|||||||
constructor: ->
|
constructor: ->
|
||||||
@message = 'Invalid credentials'
|
@message = 'Invalid credentials'
|
||||||
|
|
||||||
# Error code
|
# Error exit code
|
||||||
code: 1
|
exitCode: 1
|
||||||
|
|
||||||
exports.InvalidKey = class InvalidKey extends TypedError
|
exports.InvalidKey = class InvalidKey extends TypedError
|
||||||
|
|
||||||
@ -57,8 +57,8 @@ exports.InvalidKey = class InvalidKey extends TypedError
|
|||||||
constructor: ->
|
constructor: ->
|
||||||
@message = 'Invalid key'
|
@message = 'Invalid key'
|
||||||
|
|
||||||
# Error code
|
# Error exit code
|
||||||
code: 1
|
exitCode: 1
|
||||||
|
|
||||||
exports.InvalidPath = class InvalidPath extends TypedError
|
exports.InvalidPath = class InvalidPath extends TypedError
|
||||||
|
|
||||||
@ -73,8 +73,8 @@ exports.InvalidPath = class InvalidPath extends TypedError
|
|||||||
constructor: (path) ->
|
constructor: (path) ->
|
||||||
@message = "Invalid path: #{path}"
|
@message = "Invalid path: #{path}"
|
||||||
|
|
||||||
# Error code
|
# Error exit code
|
||||||
code: 1
|
exitCode: 1
|
||||||
|
|
||||||
exports.DirectoryDoesntExist = class DirectoryDoesntExist extends TypedError
|
exports.DirectoryDoesntExist = class DirectoryDoesntExist extends TypedError
|
||||||
|
|
||||||
@ -89,8 +89,8 @@ exports.DirectoryDoesntExist = class DirectoryDoesntExist extends TypedError
|
|||||||
constructor: (directory) ->
|
constructor: (directory) ->
|
||||||
@message = "Directory doesn't exist: #{directory}"
|
@message = "Directory doesn't exist: #{directory}"
|
||||||
|
|
||||||
# Error code
|
# Error exit code
|
||||||
code: 1
|
exitCode: 1
|
||||||
|
|
||||||
exports.NotAny = class NotAny extends TypedError
|
exports.NotAny = class NotAny extends TypedError
|
||||||
|
|
||||||
@ -105,8 +105,8 @@ exports.NotAny = class NotAny extends TypedError
|
|||||||
constructor: (name) ->
|
constructor: (name) ->
|
||||||
@message = "You don't have any #{name}"
|
@message = "You don't have any #{name}"
|
||||||
|
|
||||||
# Error code
|
# Error exit code
|
||||||
code: 0
|
exitCode: 0
|
||||||
|
|
||||||
exports.FileNotFound = class FileNotFound extends TypedError
|
exports.FileNotFound = class FileNotFound extends TypedError
|
||||||
|
|
||||||
@ -121,5 +121,5 @@ exports.FileNotFound = class FileNotFound extends TypedError
|
|||||||
constructor: (filename) ->
|
constructor: (filename) ->
|
||||||
@message = "File not found: #{filename}"
|
@message = "File not found: #{filename}"
|
||||||
|
|
||||||
# Error code
|
# Error exit code
|
||||||
code: 1
|
exitCode: 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user