diff --git a/lib/main.js b/lib/main.js index b239aed..a9ca790 100644 --- a/lib/main.js +++ b/lib/main.js @@ -950,7 +950,7 @@ they may not work as expected in the Lambda environment. } _isFunctionDoesNotExist (err) { - return err.code === 'ResourceNotFoundException' && + return err.name === 'ResourceNotFoundException' && !!err.message.match(/^Function not found:/) } diff --git a/test/main.js b/test/main.js index 8fcb2cc..b5aa2db 100644 --- a/test/main.js +++ b/test/main.js @@ -219,7 +219,7 @@ describe('lib/main', function () { describe('_isFunctionDoesNotExist', () => { it('=== true', () => { const err = { - code: 'ResourceNotFoundException', + name: 'ResourceNotFoundException', message: 'Function not found: arn:aws:lambda:XXX' } assert.isTrue(lambda._isFunctionDoesNotExist(err)) @@ -227,7 +227,7 @@ describe('lib/main', function () { it('=== false', () => { const err = { - code: 'MissingRequiredParameter', + name: 'MissingRequiredParameter', message: 'Missing required key \'FunctionName\' in params' } assert.isFalse(lambda._isFunctionDoesNotExist(err))