mapbox / cfn-config

Quickly configure, start, and update AWS CloudFormation stacks.
BSD 2-Clause "Simplified" License
53 stars 17 forks source link

Errors in lib/template.js are swallowed after file is required #117

Closed l-r closed 7 years ago

l-r commented 8 years ago

I was setting up a test stack using cfn-config and it got stuck on

Could not parse template: Failed to parse /Users/laurier/Documents/mapbox/ecs-telem-test/cloudformation/ecstelemtest.template.js

Turns out that these lines https://github.com/mapbox/cfn-config/blob/master/lib/template.js#L37-L38 require the template just fine, but then swallow errors that are thrown from the evaluation of the template. This makes it look like there's something wrong with cfn-config when in fact the real problem was somewhere else:

    template.Resources.TaskPolicy.Properties.PolicyName.indexOf(serviceName) !== 0) throw new Error('Resources.TaskPolicy should have a PolicyName that begins with "' + serviceName + '"');

Those errors should probably bubble up to let the user know that it's not strictly the template parsing that is failing.

rclark commented 8 years ago

A couple of options:

The only thing I don't want to do is abandon the typed error that this function returns under these circumstances.

l-r commented 8 years ago

The only thing I don't want to do is abandon the typed error that this function returns under these circumstances.

Agreed. I'd vote for

Could send the underlying error message and/or stack trace through