From 7f787818004dfbc6ad8ca7fec47b237bcab61a80 Mon Sep 17 00:00:00 2001 From: Sergey Bekrin Date: Wed, 23 Mar 2016 10:44:11 +0300 Subject: [PATCH] Improve error reporting when using invalid argument types for dialog API methods --- lib/browser/api/dialog.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/browser/api/dialog.js b/lib/browser/api/dialog.js index 414cd60..3a9d120 100644 --- a/lib/browser/api/dialog.js +++ b/lib/browser/api/dialog.js @@ -67,9 +67,13 @@ module.exports = { } if (options.title == null) { options.title = ''; + } else if (typeof options.title !== 'string') { + throw new TypeError('Title need to be string'); } if (options.defaultPath == null) { options.defaultPath = ''; + } else if (typeof options.defaultPath !== 'string') { + throw new TypeError('Default path need to be string'); } if (options.filters == null) { options.filters = []; @@ -91,9 +95,13 @@ module.exports = { } if (options.title == null) { options.title = ''; + } else if (typeof options.title !== 'string') { + throw new TypeError('Title need to be string'); } if (options.defaultPath == null) { options.defaultPath = ''; + } else if (typeof options.defaultPath !== 'string') { + throw new TypeError('Default path need to be string'); } if (options.filters == null) { options.filters = []; @@ -125,12 +133,18 @@ module.exports = { } if (options.title == null) { options.title = ''; + } else if (typeof options.title !== 'string') { + throw new TypeError('Title need to be string'); } if (options.message == null) { options.message = ''; + } else if (typeof options.message !== 'string') { + throw new TypeError('Message need to be string'); } if (options.detail == null) { options.detail = ''; + } else if (typeof options.detail !== 'string') { + throw new TypeError('Detail need to be string'); } if (options.icon == null) { options.icon = null; -- 2.7.4