From 5bcff712dc45a580ccebaf4d27266a117063e29b Mon Sep 17 00:00:00 2001 From: Pablo Carranza Velez Date: Tue, 1 Nov 2016 12:20:51 +0000 Subject: [PATCH] Provide a better error message when app is not found for purging --- CHANGELOG.md | 1 + src/api.coffee | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 77594b6f..21b6267a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,4 @@ +* Provide a better error message when app is not found for purging [Pablo] * Only iterate through remote apps to set device config [Pablo] # v2.8.1 diff --git a/src/api.coffee b/src/api.coffee index 3a8436e0..fef8edfe 100644 --- a/src/api.coffee +++ b/src/api.coffee @@ -113,12 +113,15 @@ module.exports = (application) -> .finally -> application.start(app) .catch (err) -> + status = 503 + if err instanceof utils.AppNotFoundError + errMsg = "App not found: an app needs to be installed for purge to work. + If you've recently moved this device from another app, + please push an app and wait for it to be installed first." + err = new Error(errMsg) + status = 400 application.logSystemMessage("Error purging /data: #{err}", { appId, error: err }, 'Purge /data error') - throw err - .catch utils.AppNotFoundError, (e) -> - return res.status(400).send(e.message) - .catch (err) -> - res.status(503).send(err?.message or err or 'Unknown error') + res.status(status).send(err?.message or err or 'Unknown error') unparsedRouter.post '/v1/tcp-ping', (req, res) -> utils.disableCheck(false)