mirror of
https://github.com/logos-storage/bittorrent-tracker.git
synced 2026-05-23 08:49:27 +00:00
don't emit 'error' for non-fatal errors
This commit is contained in:
parent
1bcb3e4097
commit
61cfe0afa6
@ -45,10 +45,14 @@ var port = 6881
|
|||||||
|
|
||||||
var client = new Client(peerId, port, parsedTorrent)
|
var client = new Client(peerId, port, parsedTorrent)
|
||||||
|
|
||||||
// you must add an 'error' event handler!
|
|
||||||
client.on('error', function (err) {
|
client.on('error', function (err) {
|
||||||
|
// fatal client error!
|
||||||
console.log(err.message)
|
console.log(err.message)
|
||||||
|
})
|
||||||
|
|
||||||
|
client.on('warning', function (err) {
|
||||||
// a tracker was unavailable or sent bad data to the client. you can probably ignore it
|
// a tracker was unavailable or sent bad data to the client. you can probably ignore it
|
||||||
|
console.log(err.message)
|
||||||
})
|
})
|
||||||
|
|
||||||
// start getting peers from the tracker
|
// start getting peers from the tracker
|
||||||
|
|||||||
@ -388,7 +388,8 @@ Tracker.prototype._requestUdp = function (requestUrl, opts) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function error (message) {
|
function error (message) {
|
||||||
self.client.emit('error', new Error(message + ' (connecting to tracker ' + requestUrl + ')'))
|
// errors will often happen if a tracker is offline, so don't treat it as fatal
|
||||||
|
self.client.emit('warning', new Error(message + ' (' + requestUrl + ')'))
|
||||||
cleanup()
|
cleanup()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -443,7 +444,7 @@ Tracker.prototype._handleResponse = function (requestUrl, data) {
|
|||||||
try {
|
try {
|
||||||
data = bencode.decode(data)
|
data = bencode.decode(data)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return self.client.emit('error', new Error('Error decoding tracker response: ' + err.message))
|
return self.client.emit('warning', new Error('Error decoding tracker response: ' + err.message))
|
||||||
}
|
}
|
||||||
var failure = data['failure reason']
|
var failure = data['failure reason']
|
||||||
if (failure) {
|
if (failure) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user