diff --git a/packages/composer-common/lib/config/configmediator.js b/packages/composer-common/lib/config/configmediator.js index e98845815a..f2c01afc85 100644 --- a/packages/composer-common/lib/config/configmediator.js +++ b/packages/composer-common/lib/config/configmediator.js @@ -46,6 +46,10 @@ class ConfigMediator { return config.get(key); } } catch (e) { + let msg = e.message; + if (msg && msg.match(/Cannot parse config file/)){ + throw e; + } // We don't care if we can't find the config module, it won't be // there when the code is running inside a webpacked or similar environment } diff --git a/packages/composer-common/test/config/configmediator.js b/packages/composer-common/test/config/configmediator.js index a99002e182..ac805f5690 100644 --- a/packages/composer-common/test/config/configmediator.js +++ b/packages/composer-common/test/config/configmediator.js @@ -97,6 +97,22 @@ describe('ConfigMediator', function() { }); }); + it('should correctly re throw the error if the config file can not be parsed', () => { + // would be good if we could get mockerty to throw an error... but have to sort of work around that.. + const mockConfig = { + has: sinon.stub().throws(new Error('Computer says Cannot parse config file huh ')), + get: sinon.stub() + }; + + mockery.registerMock('config', mockConfig); + + (()=>{ + ConfigMediator.get('thingy',{ + thingy: 'getaroundtoit' + }); + }).should.throw(/Cannot parse config file/); + }); + });