Skip to content

Commit

Permalink
Merge pull request #32 from Financial-Times/throw-errors-not-strings
Browse files Browse the repository at this point in the history
Throw errors not strings
  • Loading branch information
callumlocke authored Oct 28, 2016
2 parents 85b5389 + 6d23725 commit d8a21c4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/poller.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = EventEmitter => {
constructor(config){
super();
if (!config.url) {
throw 'ft-poller expects a url';
throw new Error('ft-poller expects a url');
}

this.url = config.url;
Expand Down Expand Up @@ -82,7 +82,7 @@ module.exports = EventEmitter => {
if (response.status === 200) {
this.emit('ok', response, latency);
} else {
throw `Fetching ${response.url} failed with a ${response.status}, ${response.statusText}`;
throw new Error(`Fetching ${response.url} failed with a ${response.status}, ${response.statusText}`);
}
if ((response.headers.get('content-type') || '').indexOf('json') > -1) {
return response.json();
Expand Down

0 comments on commit d8a21c4

Please sign in to comment.