From 4670ae125b300e0a58a077d86f0a3194026dc765 Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Wed, 22 Jun 2016 10:40:51 -0400 Subject: [PATCH] fix: ensure dialog.showErrorBox() arguments are strings (#497) If for some reason either the error title or message are not strings, the user gets a very obscure error that looks something like this: ``` Error: Could not call remote function ''. Check that the function signature is correct. Underlying error: Error processing argument at index 0, conversion failure ``` What's even worse is that the above error is thrown when we attempt to display an `Error` object, therefore completely hiding the real error. In this commit, we make sure both parameters to `showErrorBox()` are strings, as a safety measure to prevent this from happening again. See: https://github.com/resin-io/etcher/issues/127 Signed-off-by: Juan Cruz Viotti --- lib/gui/os/dialog/services/dialog.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/gui/os/dialog/services/dialog.js b/lib/gui/os/dialog/services/dialog.js index 5c2b9101..91b1b005 100644 --- a/lib/gui/os/dialog/services/dialog.js +++ b/lib/gui/os/dialog/services/dialog.js @@ -107,7 +107,18 @@ module.exports = function($q, SupportedFormatsModel) { }); const message = description || error.stack || JSON.stringify(error) || ''; - electron.remote.dialog.showErrorBox(title, message); + + // Ensure the parameters are strings to prevent the following + // types of obscure errors: + // + // Error: Could not call remote function ''. + // Check that the function signature is correct. + // Underlying error: + // Error processing argument at index 0, conversion failure + // + // This can be thrown if for some reason, either `title` or `message` + // are not strings. + electron.remote.dialog.showErrorBox(title.toString(), message.toString()); }; };