Merge pull request #56 from resin-io/jviotti/feat/50/error-dialogs

Show error dialogs on JavaScript exceptions
This commit is contained in:
Juan Cruz Viotti 2015-11-30 15:10:36 -04:00
commit 1f8aeac59c
4 changed files with 30 additions and 6 deletions

View File

@ -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);
};
/**

View File

@ -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;

View File

@ -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);
};
/**

View File

@ -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 || '');
};