diff options
author | Feross Aboukhadijeh <feross@feross.org> | 2017-01-20 02:29:33 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-20 02:29:33 +0300 |
commit | 62e96d85be82bef4fd511399678972e8954fddaf (patch) | |
tree | 87eb2f5929cee52d49608929321e2acb041f255a /lib | |
parent | 0bda84ff6c7a2ab5a5517ed515ca8aef2983bb86 (diff) | |
parent | 6870e7c7450ea9f3379a053189187e9c99c8b067 (diff) |
Merge pull request #1021 from feross/emit-more-warnings
Emit more warnings
Diffstat (limited to 'lib')
-rw-r--r-- | lib/torrent.js | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/torrent.js b/lib/torrent.js index 21b19af..093e6b5 100644 --- a/lib/torrent.js +++ b/lib/torrent.js @@ -389,7 +389,7 @@ Torrent.prototype._getMetadataFromServer = function () { function getMetadataFromURL (url, cb) { if (url.indexOf('http://') !== 0 && url.indexOf('https://') !== 0) { - self._debug('skipping non-http xs param: %s', url) + self.emit('warning', new Error('skipping non-http xs param: ' + url)) return cb(null) } @@ -404,7 +404,7 @@ Torrent.prototype._getMetadataFromServer = function () { try { req = get.concat(opts, onResponse) } catch (err) { - self._debug('skipping invalid url xs param: %s', url) + self.emit('warning', new Error('skipping invalid url xs param: ' + url)) return cb(null) } @@ -415,11 +415,11 @@ Torrent.prototype._getMetadataFromServer = function () { if (self.metadata) return cb(null) if (err) { - self._debug('http error from xs param: %s', url) + self.emit('warning', new Error('http error from xs param: ' + url)) return cb(null) } if (res.statusCode !== 200) { - self._debug('non-200 status code %s from xs param: %s', res.statusCode, url) + self.emit('warning', new Error('non-200 status code ' + res.statusCode + ' from xs param: ' + url)) return cb(null) } @@ -429,12 +429,12 @@ Torrent.prototype._getMetadataFromServer = function () { } catch (err) {} if (!parsedTorrent) { - self._debug('got invalid torrent file from xs param: %s', url) + self.emit('warning', new Error('got invalid torrent file from xs param: ' + url)) return cb(null) } if (parsedTorrent.infoHash !== self.infoHash) { - self._debug('got torrent file with incorrect info hash from xs param: %s', url) + self.emit('warning', new Error('got torrent file with incorrect info hash from xs param: ' + url)) return cb(null) } @@ -797,13 +797,13 @@ Torrent.prototype.addWebSeed = function (url) { if (this.destroyed) throw new Error('torrent is destroyed') if (!/^https?:\/\/.+/.test(url)) { - this._debug('ignoring invalid web seed %s', url) + this.emit('warning', new Error('ignoring invalid web seed: ' + url)) this.emit('invalidPeer', url) return } if (this._peers[url]) { - this._debug('ignoring duplicate web seed %s', url) + this.emit('warning', new Error('ignoring duplicate web seed: ' + url)) this.emit('invalidPeer', url) return } |