diff --git a/build/browser/app.js b/build/browser/app.js index a9a8d0ac..27f66d8d 100644 --- a/build/browser/app.js +++ b/build/browser/app.js @@ -79,7 +79,7 @@ app.controller('AppController', function($q, DriveScannerService, SelectionState console.debug('Burning ' + image + ' to ' + drive.device); return self.writer.burn(image, drive).then(function() { console.debug('Done!'); - }); + }).catch(dialog.showError); }; this.open = shell.openExternal; @@ -119,9 +119,13 @@ var _ = require('lodash'); var remote = window.require('remote'); if (window.mocha) { - var drives = remote.require(require('path').join(__dirname, '..', '..', 'src', 'drives')); + var path = require('path'); + var srcPath = path.join(__dirname, '..', '..', 'src'); + var drives = remote.require(path.join(srcPath, 'drives')); + var dialog = remote.require(path.join(srcPath, 'dialog')); } else { var drives = remote.require('./src/drives'); + var dialog = remote.require('./src/dialog'); } var driveScanner = angular.module('herostratus.drive-scanner', []); @@ -227,7 +231,7 @@ driveScanner.service('DriveScannerService', function($q, DriveScannerRefreshServ * }); */ this.scan = function() { - return $q.when(drives.listRemovable()); + return $q.when(drives.listRemovable()).catch(dialog.showError); }; /** diff --git a/lib/browser/app.js b/lib/browser/app.js index f8226494..bfa05953 100644 --- a/lib/browser/app.js +++ b/lib/browser/app.js @@ -78,7 +78,7 @@ app.controller('AppController', function($q, DriveScannerService, SelectionState console.debug('Burning ' + image + ' to ' + drive.device); return self.writer.burn(image, drive).then(function() { console.debug('Done!'); - }); + }).catch(dialog.showError); }; this.open = shell.openExternal; diff --git a/lib/browser/modules/drive-scanner.js b/lib/browser/modules/drive-scanner.js index 607293c2..01732fae 100644 --- a/lib/browser/modules/drive-scanner.js +++ b/lib/browser/modules/drive-scanner.js @@ -30,9 +30,13 @@ var _ = require('lodash'); var remote = window.require('remote'); if (window.mocha) { - var drives = remote.require(require('path').join(__dirname, '..', '..', 'src', 'drives')); + var path = require('path'); + var srcPath = path.join(__dirname, '..', '..', 'src'); + var drives = remote.require(path.join(srcPath, 'drives')); + var dialog = remote.require(path.join(srcPath, 'dialog')); } else { var drives = remote.require('./src/drives'); + var dialog = remote.require('./src/dialog'); } var driveScanner = angular.module('herostratus.drive-scanner', []); @@ -138,7 +142,7 @@ driveScanner.service('DriveScannerService', function($q, DriveScannerRefreshServ * }); */ this.scan = function() { - return $q.when(drives.listRemovable()); + return $q.when(drives.listRemovable()).catch(dialog.showError); }; /** diff --git a/lib/src/dialog.js b/lib/src/dialog.js index 796c9426..5b7b6659 100644 --- a/lib/src/dialog.js +++ b/lib/src/dialog.js @@ -55,3 +55,19 @@ exports.selectImage = function() { }); }); }; + +/** + * @summary Show error dialog for an Error instance + * @function + * @public + * + * @param {Error} error - error + * + * @example + * dialog.showError(new Error('Foo Bar')); + */ +exports.showError = function(error) { + 'use strict'; + + dialog.showErrorBox(error.message, error.stack || ''); +};