Skip to content

Commit db2cdaf

Browse files
committed
Merge pull request #62 from iRyusa/getFetcher-debug-name
A more helpful error message for getFetcher
2 parents 315801d + 5f0ce1e commit db2cdaf

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

libs/fetcher.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ var OP_READ = 'read',
5959
Fetcher.getFetcher = function (name) {
6060
//Access fetcher by name
6161
if (!name || !Fetcher.fetchers[name]) {
62-
throw new Error('Fetcher could not be found');
62+
throw new Error('Fetcher "' + name + '" could not be found');
6363
}
6464
return Fetcher.fetchers[name];
6565
};

tests/unit/libs/fetcher.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ var expect = chai.expect,
2121
describe('Server Fetcher', function () {
2222

2323
it('should register fetchers', function () {
24-
var fn = Fetcher.getFetcher.bind(fetcher, mockFetcher.name);
24+
var fn = Fetcher.getFetcher.bind(fetcher);
25+
expect(fn).to.throw(Error, 'Fetcher "undefined" could not be found');
26+
fn = Fetcher.getFetcher.bind(fetcher, mockFetcher.name);
2527
expect(_.size(Fetcher.fetchers)).to.equal(0);
26-
expect(fn).to.throw(Error, 'Fetcher could not be found');
28+
expect(fn).to.throw(Error, 'Fetcher "' + mockFetcher.name + '" could not be found');
2729
Fetcher.registerFetcher(mockFetcher);
2830
expect(_.size(Fetcher.fetchers)).to.equal(1);
2931
expect(fn()).to.deep.equal(mockFetcher);

0 commit comments

Comments
 (0)