From 7d5f42f38c99ea8c234dca2c9df276452df3bedd Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Wed, 8 Jun 2016 15:49:42 -0400 Subject: [PATCH] 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 --- lib/gui/os/dialog/services/dialog.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/gui/os/dialog/services/dialog.js b/lib/gui/os/dialog/services/dialog.js index 96319f83..49152727 100644 --- a/lib/gui/os/dialog/services/dialog.js +++ b/lib/gui/os/dialog/services/dialog.js @@ -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.