Try to get more information about error messages (#464)

If the error object is not well-formed, try to get as most information
about it as we can instead of just realying on generic error messages.

Signed-off-by: Juan Cruz Viotti <jviottidc@gmail.com>
This commit is contained in:
Juan Cruz Viotti 2016-06-08 15:49:42 -04:00
parent f2a8860135
commit 7d5f42f38c

View File

@ -88,7 +88,13 @@ module.exports = function($q, SupportedFormatsModel) {
*/
this.showError = function(error) {
error = error || {};
electron.remote.dialog.showErrorBox(error.message || 'An error ocurred!', error.stack || '');
// Try to get as most information as possible about the error
// rather than falling back to generic messages right away.
const title = error.message || error.code || 'An error ocurred';
const message = error.stack || JSON.stringify(error) || '';
electron.remote.dialog.showErrorBox(title, message);
// Also throw it so it gets displayed in DevTools
// and its reported by TrackJS.