diff --git a/lib/actions/environment-variables.coffee b/lib/actions/environment-variables.coffee index fb97825b..ff703e84 100644 --- a/lib/actions/environment-variables.coffee +++ b/lib/actions/environment-variables.coffee @@ -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')) diff --git a/lib/actions/keys.coffee b/lib/actions/keys.coffee index 3f8cc8fd..773cefa6 100644 --- a/lib/actions/keys.coffee +++ b/lib/actions/keys.coffee @@ -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' ])) diff --git a/lib/models/application.coffee b/lib/models/application.coffee index 243006bb..52ed981c 100644 --- a/lib/models/application.coffee +++ b/lib/models/application.coffee @@ -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 diff --git a/lib/models/environment-variables.coffee b/lib/models/environment-variables.coffee index b6fb3045..06282a79 100644 --- a/lib/models/environment-variables.coffee +++ b/lib/models/environment-variables.coffee @@ -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) ->