diff --git a/src/apps.js b/src/apps.js index ef48ddaff..e50f28e09 100644 --- a/src/apps.js +++ b/src/apps.js @@ -293,6 +293,7 @@ function purchase(appStoreId, callback) { superagent.post(url).query({ token: config.token() }).end(function (error, res) { if (error) return callback(new AppsError(AppsError.INTERNAL_ERROR, error)); if (res.status === 402) return callback(new AppsError(AppsError.BILLING_REQUIRED)); + if (res.status === 404) return callback(new AppsError(AppsError.NOT_FOUND)); if (res.status !== 201 && res.status !== 200) return callback(new Error(util.format('App purchase failed. %s %j', res.status, res.body))); callback(null); diff --git a/src/routes/apps.js b/src/routes/apps.js index 2931a7e0a..2c7cd040a 100644 --- a/src/routes/apps.js +++ b/src/routes/apps.js @@ -133,6 +133,7 @@ function installApp(req, res, next) { if (error && error.reason === AppsError.PORT_CONFLICT) return next(new HttpError(409, 'Port ' + error.message + ' is already in use.')); if (error && error.reason === AppsError.BAD_FIELD) return next(new HttpError(400, error.message)); if (error && error.reason === AppsError.BILLING_REQUIRED) return next(new HttpError(402, 'Billing required')); + if (error && error.reason === AppsError.NOT_FOUND) return next(new HttpError(404, 'No such app')); if (error && error.reason === AppsError.BAD_CERTIFICATE) return next(new HttpError(400, error.message)); if (error && error.reason === AppsError.USER_REQUIRED) return next(new HttpError(400, 'accessRestriction must specify one user')); if (error) return next(new HttpError(500, error));