Fix the message shown when docker gives a 500 error when starting a container

The test for an exec format error caused a `err.json.trim` is not a function
error so the message shown didn't relate to what the problem actually was.
This makes the test for the exec format error safer.

Change-Type: patch
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
This commit is contained in:
Pablo Carranza Velez 2017-07-26 10:41:25 -03:00
parent 49d149a196
commit 279ab60233

View File

@ -244,6 +244,12 @@ shouldMountKmod = (image) ->
console.error('Error getting app OS release: ', err)
return false
isExecFormatError = (err) ->
message = ''
try
message = err.json.trim()
/exec format error$/.test(message)
application.start = start = (app) ->
device.isResinOSv1().then (isV1) ->
volumes = utils.defaultVolumes(isV1)
@ -319,7 +325,7 @@ application.start = start = (app) ->
alreadyStarted = true
return
if statusCode is '500' and err.json.trim().match(/exec format error$/)
if statusCode is '500' and isExecFormatError(err)
# Provide a friendlier error message for "exec format error"
device.getDeviceType()
.then (deviceType) ->