Move error definitions to errors.js (#898)

This commit is contained in:
Adam Gotlib
2016-09-07 22:21:59 +02:00
committed by DC
parent d88229694a
commit d331bae548
9 changed files with 76 additions and 26 deletions

View File

@@ -3,6 +3,7 @@ const path = require('path')
const electron = require('electron')
const {dispatch} = require('../lib/dispatcher')
const {TorrentKeyNotFoundError} = require('../lib/errors')
const State = require('../lib/state')
const sound = require('../lib/sound')
const TorrentSummary = require('../lib/torrent-summary')
@@ -75,7 +76,7 @@ module.exports = class TorrentListController {
// Starts downloading and/or seeding a given torrentSummary.
startTorrentingSummary (torrentKey) {
const s = TorrentSummary.getByKey(this.state, torrentKey)
if (!s) throw new Error('Missing key: ' + torrentKey)
if (!s) throw new TorrentKeyNotFoundError(torrentKey)
// New torrent: give it a path
if (!s.path) {