Treat the bluebird OperationalError wrapper correctly.

This commit is contained in:
Pagan Gazzard 2014-08-08 11:18:37 +01:00 committed by Pablo Carranza Vélez
parent 0fae904f1c
commit 51bfb69354

View File

@ -53,9 +53,10 @@ exports.kill = kill = (app) ->
container.stopAsync()
.then ->
container.removeAsync()
.catch (err) ->
# Make sure statusCode is definitely a string, for comparison reasons.
statusCode = '' + err.statusCode
# Bluebird throws OperationalError for errors resulting in the normal execution of a promisified function.
.catch Promise.OperationalError, (err) ->
# Get the statusCode from the original cause and make sure statusCode its definitely a string for comparison reasons.
statusCode = '' + err.cause.statusCode
# 304 means the container was already stopped - so we can just remove it
if statusCode is '304'
return container.removeAsync()