From 6d237253a0dc8c60e9215c07c20b1a6e836b92b4 Mon Sep 17 00:00:00 2001 From: Callum Locke Date: Fri, 28 Oct 2016 13:11:21 +0100 Subject: [PATCH] throw errors not strings --- src/poller.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/poller.js b/src/poller.js index 89aadb9..0931662 100644 --- a/src/poller.js +++ b/src/poller.js @@ -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; @@ -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();