Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorFeross Aboukhadijeh <feross@feross.org>2016-07-27 07:21:41 +0300
committerFeross Aboukhadijeh <feross@feross.org>2016-07-27 07:50:16 +0300
commita9ec9dc78c6f383474b81daa71cb0c8194a1085e (patch)
treecf620cff901e10fd6b16e3494595e74f8185c3c0 /lib
parentd13b062201a9ce80c9c38e96fe279db6fe5c89e5 (diff)
Clarify 'error' event handling in docs
Diffstat (limited to 'lib')
-rw-r--r--lib/torrent.js13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/torrent.js b/lib/torrent.js
index e4bedef..5d2150b 100644
--- a/lib/torrent.js
+++ b/lib/torrent.js
@@ -677,12 +677,13 @@ Torrent.prototype._destroy = function (err, cb) {
parallel(tasks, cb)
if (err) {
- // Torrent errors are emitted at `torrent.on('error')`. If there are no 'error' event
- // handlers on the torrent instance, the error will be emitted at
- // `client.on('error')`. This prevents crashing the user's program, but it makes it
- // impossible to determine a client error versus a torrent error (where the client
- // is still usable afterwards). Users are recommended for errors in both places
- // to distinguish between the error types.
+ // Torrent errors are emitted at `torrent.on('error')`. If there are no 'error'
+ // event handlers on the torrent instance, then the error will be emitted at
+ // `client.on('error')`. This prevents throwing an uncaught exception
+ // (unhandled 'error' event), but it makes it impossible to distinguish client
+ // errors versus torrent errors. Torrent errors are not fatal, and the client
+ // is still usable afterwards. Therefore, always listen for errors in both
+ // places (`client.on('error')` and `torrent.on('error')`).
if (self.listenerCount('error') === 0) {
self.client.emit('error', err)
} else {