mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-20 22:23:07 +00:00
Make use of errors.NotFound
This commit is contained in:
parent
86548fc3d2
commit
927b7bc0eb
@ -12,7 +12,7 @@ isSystemVariable = (environmentVariable) ->
|
||||
SYSTEM_VAR_REGEX.test(environmentVariable.name)
|
||||
|
||||
exports.list = authHooks.failIfNotLoggedIn (program) ->
|
||||
applicationId = program.parent.application
|
||||
applicationId = program.parent?.application
|
||||
|
||||
if not applicationId?
|
||||
errors.handle(new Error('You have to specify an application'))
|
||||
|
@ -27,7 +27,7 @@ exports.info = authHooks.failIfNotLoggedIn (id) ->
|
||||
errors.handle(error) if error?
|
||||
key = _.findWhere(keys, { id })
|
||||
if not key?
|
||||
errors.handle(new Error("Key #{id} doesn't exists"))
|
||||
errors.handle(new errors.NotFound("key #{id}"))
|
||||
|
||||
key.public_key = '\n' + helpers.formatLongString(key.public_key, config.sshKeyWidth)
|
||||
log.out(table.vertical(key, _.identity, [ 'ID', 'Title', 'Public Key' ]))
|
||||
|
@ -1,5 +1,6 @@
|
||||
Promise = require('bluebird')
|
||||
canvas = require('./_canvas')
|
||||
errors = require('../errors/errors')
|
||||
|
||||
exports.getAll = ->
|
||||
return canvas.get
|
||||
@ -15,7 +16,7 @@ exports.get = (id) ->
|
||||
|
||||
.then (application) ->
|
||||
if not application?
|
||||
return Promise.reject(new Error('Not found'))
|
||||
return Promise.reject(new errors.NotFound("application #{id}"))
|
||||
|
||||
return application
|
||||
|
||||
@ -30,7 +31,7 @@ exports.create = (name, deviceType) ->
|
||||
id = res?.id
|
||||
|
||||
if not id?
|
||||
return Promise.reject(new Error('Could not find created application id.'))
|
||||
return Promise.reject(new errors.NotFound('created application id'))
|
||||
|
||||
return id
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
Promise = require('bluebird')
|
||||
canvas = require('./_canvas')
|
||||
errors = require('../errors/errors')
|
||||
|
||||
exports.getAll = (applicationId) ->
|
||||
return canvas.get
|
||||
@ -11,7 +12,7 @@ exports.getAll = (applicationId) ->
|
||||
|
||||
.then (environmentVariables) ->
|
||||
if not environmentVariables?
|
||||
return Promise.reject(new Error('Not found'))
|
||||
return Promise.reject(new errors.NotFound('environment variables'))
|
||||
return environmentVariables
|
||||
|
||||
exports.remove = (id) ->
|
||||
|
Loading…
Reference in New Issue
Block a user