Provide a better error message when app is not found for purging

This commit is contained in:
Pablo Carranza Velez 2016-11-01 12:20:51 +00:00
parent f38715177f
commit 5bcff712dc
2 changed files with 9 additions and 5 deletions

View File

@ -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

View File

@ -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)