Skip to content

Commit

Permalink
rethrow error if can not parse config file (hyperledger-archives#3519)
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew B White <[email protected]>
  • Loading branch information
mbwhite authored and nklincoln committed Mar 2, 2018
1 parent cf8ac15 commit 8e3164c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/composer-common/lib/config/configmediator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
16 changes: 16 additions & 0 deletions packages/composer-common/test/config/configmediator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/);
});

});


Expand Down

0 comments on commit 8e3164c

Please sign in to comment.