Fix unhandled 'error' dispatch (#708)

* fix 'error' dispatch

* directly call functions defined in main
This commit is contained in:
Mathias Rasmussen
2016-07-14 23:04:25 +02:00
committed by DC
parent be1314422d
commit f0aeab0207
2 changed files with 7 additions and 7 deletions

View File

@@ -207,7 +207,7 @@ function findFilesRecursive (paths, cb) {
var fileOrFolder = paths[0] var fileOrFolder = paths[0]
fs.stat(fileOrFolder, function (err, stat) { fs.stat(fileOrFolder, function (err, stat) {
if (err) return dispatch('onError', err) if (err) return dispatch('error', err)
// Files: return name, path, and size // Files: return name, path, and size
if (!stat.isDirectory()) { if (!stat.isDirectory()) {
@@ -222,7 +222,7 @@ function findFilesRecursive (paths, cb) {
// Folders: recurse, make a list of all the files // Folders: recurse, make a list of all the files
var folderPath = fileOrFolder var folderPath = fileOrFolder
fs.readdir(folderPath, function (err, fileNames) { fs.readdir(folderPath, function (err, fileNames) {
if (err) return dispatch('onError', err) if (err) return dispatch('error', err)
var paths = fileNames.map((fileName) => path.join(folderPath, fileName)) var paths = fileNames.map((fileName) => path.join(folderPath, fileName))
findFilesRecursive(paths, cb) findFilesRecursive(paths, cb)
}) })
@@ -257,9 +257,9 @@ function saveTorrentFileAs (torrentSummary) {
electron.remote.dialog.showSaveDialog(electron.remote.getCurrentWindow(), opts, function (savePath) { electron.remote.dialog.showSaveDialog(electron.remote.getCurrentWindow(), opts, function (savePath) {
var torrentPath = TorrentSummary.getTorrentPath(torrentSummary) var torrentPath = TorrentSummary.getTorrentPath(torrentSummary)
fs.readFile(torrentPath, function (err, torrentFile) { fs.readFile(torrentPath, function (err, torrentFile) {
if (err) return dispatch('onError', err) if (err) return dispatch('error', err)
fs.writeFile(savePath, torrentFile, function (err) { fs.writeFile(savePath, torrentFile, function (err) {
if (err) return dispatch('onError', err) if (err) return dispatch('error', err)
}) })
}) })
}) })

View File

@@ -231,13 +231,13 @@ const dispatchHandlers = {
'forward': () => state.location.forward(), 'forward': () => state.location.forward(),
// Controlling the window // Controlling the window
'setDimensions': (dimensions) => setDimensions(dimensions), 'setDimensions': setDimensions,
'toggleFullScreen': (setTo) => ipcRenderer.send('toggleFullScreen', setTo), 'toggleFullScreen': (setTo) => ipcRenderer.send('toggleFullScreen', setTo),
'setTitle': (title) => { state.window.title = title }, 'setTitle': (title) => { state.window.title = title },
// Everything else // Everything else
'onOpen': (files) => onOpen(files), 'onOpen': onOpen,
'onError': (err) => onError(err), 'error': onError,
'uncaughtError': (proc, err) => telemetry.logUncaughtError(proc, err), 'uncaughtError': (proc, err) => telemetry.logUncaughtError(proc, err),
'saveState': () => State.save(state) 'saveState': () => State.save(state)
} }