From 812ce8724d8a92a68ec9be670fa6577930e5b0ca Mon Sep 17 00:00:00 2001 From: DC Date: Tue, 19 Apr 2016 20:09:28 -0700 Subject: [PATCH] Show an error when adding an invalid magnet link (#428) Fixes #386 --- renderer/webtorrent.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/renderer/webtorrent.js b/renderer/webtorrent.js index f51b3283..e5a9cf4a 100644 --- a/renderer/webtorrent.js +++ b/renderer/webtorrent.js @@ -68,10 +68,15 @@ function init () { // See https://github.com/feross/webtorrent/blob/master/docs/api.md#clientaddtorrentid-opts-function-ontorrent-torrent- function startTorrenting (torrentKey, torrentID, path, fileModtimes) { console.log('starting torrent %s: %s', torrentKey, torrentID) - var torrent = client.add(torrentID, { - path: path, - fileModtimes: fileModtimes - }) + var torrent + try { + torrent = client.add(torrentID, { + path: path, + fileModtimes: fileModtimes + }) + } catch (err) { + return ipc.send('wt-error', torrentKey, err.message) + } torrent.key = torrentKey addTorrentEvents(torrent) return torrent