refactor: use TypeError
instead of generic Error
when appropriate (#39209)
refactor: use TypeError instead of generic Error when appropriate
This commit is contained in:
parent
77cc1d6ffa
commit
455f57322f
9 changed files with 13 additions and 13 deletions
|
@ -24,12 +24,12 @@ class AutoUpdater extends EventEmitter {
|
|||
if (typeof options.url === 'string') {
|
||||
updateURL = options.url;
|
||||
} else {
|
||||
throw new Error('Expected options object to contain a \'url\' string property in setFeedUrl call');
|
||||
throw new TypeError('Expected options object to contain a \'url\' string property in setFeedUrl call');
|
||||
}
|
||||
} else if (typeof options === 'string') {
|
||||
updateURL = options;
|
||||
} else {
|
||||
throw new Error('Expected an options object with a \'url\' property to be provided');
|
||||
throw new TypeError('Expected an options object with a \'url\' property to be provided');
|
||||
}
|
||||
this.updateURL = updateURL;
|
||||
}
|
||||
|
|
|
@ -331,7 +331,7 @@ class TouchBar extends EventEmitter implements Electron.TouchBar {
|
|||
const idSet = new Set();
|
||||
items.forEach((item) => {
|
||||
if (!(item instanceof TouchBarItem)) {
|
||||
throw new Error('Each item must be an instance of TouchBarItem');
|
||||
throw new TypeError('Each item must be an instance of TouchBarItem');
|
||||
}
|
||||
|
||||
if (item.type === 'other_items_proxy') {
|
||||
|
|
|
@ -34,19 +34,19 @@ class ForkUtilityProcess extends EventEmitter {
|
|||
|
||||
if (options.execArgv != null) {
|
||||
if (!Array.isArray(options.execArgv)) {
|
||||
throw new Error('execArgv must be an array of strings.');
|
||||
throw new TypeError('execArgv must be an array of strings.');
|
||||
}
|
||||
}
|
||||
|
||||
if (options.serviceName != null) {
|
||||
if (typeof options.serviceName !== 'string') {
|
||||
throw new Error('serviceName must be a string.');
|
||||
throw new TypeError('serviceName must be a string.');
|
||||
}
|
||||
}
|
||||
|
||||
if (options.cwd != null) {
|
||||
if (typeof options.cwd !== 'string') {
|
||||
throw new Error('cwd path must be a string.');
|
||||
throw new TypeError('cwd path must be a string.');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -411,7 +411,7 @@ WebContents.prototype.getPrintersAsync = async function () {
|
|||
|
||||
WebContents.prototype.loadFile = function (filePath, options = {}) {
|
||||
if (typeof filePath !== 'string') {
|
||||
throw new Error('Must pass filePath as a string');
|
||||
throw new TypeError('Must pass filePath as a string');
|
||||
}
|
||||
const { query, search, hash } = options;
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ Object.defineProperty(WebFrameMain.prototype, 'ipc', {
|
|||
|
||||
WebFrameMain.prototype.send = function (channel, ...args) {
|
||||
if (typeof channel !== 'string') {
|
||||
throw new Error('Missing required channel argument');
|
||||
throw new TypeError('Missing required channel argument');
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -25,7 +25,7 @@ WebFrameMain.prototype.send = function (channel, ...args) {
|
|||
|
||||
WebFrameMain.prototype._sendInternal = function (channel, ...args) {
|
||||
if (typeof channel !== 'string') {
|
||||
throw new Error('Missing required channel argument');
|
||||
throw new TypeError('Missing required channel argument');
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue