Merge pull request #4887 from sergeybekrin/master

Improve error reporting when passing invalid argument types for dialog API methods
This commit is contained in:
Kevin Sawicki 2016-03-30 16:34:42 -07:00
commit 8bcede8019

View file

@ -56,7 +56,7 @@ module.exports = {
options.properties = ['openFile'];
}
if (!Array.isArray(options.properties)) {
throw new TypeError('Properties need to be array');
throw new TypeError('Properties must be an array');
}
properties = 0;
for (prop in fileDialogProperties) {
@ -67,9 +67,13 @@ module.exports = {
}
if (options.title == null) {
options.title = '';
} else if (typeof options.title !== 'string') {
throw new TypeError('Title must be a string');
}
if (options.defaultPath == null) {
options.defaultPath = '';
} else if (typeof options.defaultPath !== 'string') {
throw new TypeError('Default path must be a 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 must be a string');
}
if (options.defaultPath == null) {
options.defaultPath = '';
} else if (typeof options.defaultPath !== 'string') {
throw new TypeError('Default path must be a string');
}
if (options.filters == null) {
options.filters = [];
@ -121,16 +129,22 @@ module.exports = {
throw new TypeError('Invalid message box type');
}
if (!Array.isArray(options.buttons)) {
throw new TypeError('Buttons need to be array');
throw new TypeError('Buttons must be an array');
}
if (options.title == null) {
options.title = '';
} else if (typeof options.title !== 'string') {
throw new TypeError('Title must be a string');
}
if (options.message == null) {
options.message = '';
} else if (typeof options.message !== 'string') {
throw new TypeError('Message must be a string');
}
if (options.detail == null) {
options.detail = '';
} else if (typeof options.detail !== 'string') {
throw new TypeError('Detail must be a string');
}
if (options.icon == null) {
options.icon = null;