mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2025-01-18 20:21:36 +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)
|
||||
|
||||
// you must add an 'error' event handler!
|
||||
client.on('error', function (err) {
|
||||
// fatal client error!
|
||||
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
|
||||
console.log(err.message)
|
||||
})
|
||||
|
||||
// start getting peers from the tracker
|
||||
|
@ -388,7 +388,8 @@ Tracker.prototype._requestUdp = function (requestUrl, opts) {
|
||||
}
|
||||
|
||||
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()
|
||||
}
|
||||
|
||||
@ -443,7 +444,7 @@ Tracker.prototype._handleResponse = function (requestUrl, data) {
|
||||
try {
|
||||
data = bencode.decode(data)
|
||||
} 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']
|
||||
if (failure) {
|
||||
|
Loading…
Reference in New Issue
Block a user