Fix problem catching errors when killing a container that doesn't exist

We've been using `.catch Promise.OperationalError, ...` to catch errors when stopping a container and
detecting whether the error means that the container has already been stopped of removed.

Apparently, after the recent dockerode upgrade these errors are not typed as OperationalError anymore, causing error
messages like "No such container: null" when applying an update. This commit makes us catch all errors and check for their statusCode.

Change-Type: patch
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
This commit is contained in:
Pablo Carranza Velez 2017-09-05 20:17:43 -07:00
parent 64eb5f4f24
commit 81a6c2f344

View File

@ -162,8 +162,7 @@ application.kill = kill = (app, { updateDB = true, removeContainer = true } = {}
.then ->
container.remove(v: true) if removeContainer
return
# Bluebird throws OperationalError for errors resulting in the normal execution of a promisified function.
.catch Promise.OperationalError, (err) ->
.catch (err) ->
# Get the statusCode from the original cause and make sure statusCode its definitely a string for comparison
# reasons.
statusCode = '' + err.statusCode