Skip to content

Commit 5bc1b50

Browse files
committed
client: make tracker errors into 'warning' events
trackers failing to respond or giving non-200 http status codes is not a fatal error
1 parent ce171f1 commit 5bc1b50

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

client.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ Tracker.prototype._requestHttp = function (requestUrl, opts) {
241241
var req = http.get(fullUrl, function (res) {
242242
if (res.statusCode !== 200) {
243243
res.resume() // consume the whole stream
244-
self.client.emit('error', new Error('Invalid response code ' + res.statusCode + ' from tracker ' + requestUrl))
244+
self.client.emit('warning', new Error('Invalid response code ' + res.statusCode + ' from tracker ' + requestUrl))
245245
return
246246
}
247247
res.pipe(concat(function (data) {
@@ -250,7 +250,7 @@ Tracker.prototype._requestHttp = function (requestUrl, opts) {
250250
})
251251

252252
req.on('error', function (err) {
253-
self.client.emit('error', err)
253+
self.client.emit('warning', err)
254254
})
255255
}
256256

@@ -418,12 +418,12 @@ Tracker.prototype._handleResponse = function (requestUrl, data) {
418418
}
419419
var failure = data['failure reason']
420420
if (failure) {
421-
return self.client.emit('error', new Error(failure))
421+
return self.client.emit('warning', new Error(failure))
422422
}
423423

424424
var warning = data['warning message']
425425
if (warning) {
426-
self.client.emit('warning', warning)
426+
self.client.emit('warning', new Error(warning))
427427
}
428428

429429
if (requestUrl === self._announceUrl) {
@@ -464,7 +464,7 @@ Tracker.prototype._handleResponse = function (requestUrl, data) {
464464
data = data[common.bytewiseEncodeURIComponent(self.client._infoHash)]
465465

466466
if (!data) {
467-
self.client.emit('error', new Error('invalid scrape response'))
467+
self.client.emit('warning', new Error('invalid scrape response'))
468468
} else {
469469
// TODO: optionally handle data.flags.min_request_interval (separate from announce interval)
470470
self.client.emit('scrape', {

0 commit comments

Comments
 (0)