mirror of
https://github.com/balena-io/etcher.git
synced 2025-04-24 07:17:18 +00:00
Merge pull request #56 from resin-io/jviotti/feat/50/error-dialogs
Show error dialogs on JavaScript exceptions
This commit is contained in:
commit
1f8aeac59c
@ -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);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -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 || '');
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user