1
1
mirror of https://github.com/n8n-io/n8n.git synced 2024-12-29 15:14:40 +03:00

refactor: catch doesn't need to have a param (no-changelog) (#5614)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™ 2023-03-03 18:18:49 +01:00 committed by GitHub
parent 9420b0fdf8
commit 4e244937c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 59 additions and 59 deletions

View File

@ -88,7 +88,7 @@ export const executeCommand = async (
try {
await fsAccess(downloadFolder);
} catch (_) {
} catch {
await fsMkdir(downloadFolder);
// Also init the folder since some versions
// of npm complain if the folder is empty
@ -154,7 +154,7 @@ export function matchMissingPackages(
return parsedPackageData.packageName;
// eslint-disable-next-line no-empty
} catch (_) {}
} catch {}
return undefined;
});

View File

@ -125,7 +125,7 @@ const isJsonRequest = (curlJson: CurlJson): boolean => {
try {
JSON.parse(bodyKey);
return true;
} catch (_) {
} catch {
return false;
}
}

View File

@ -217,7 +217,7 @@ export class LoadNodesAndCredentials implements INodesAndCredentials {
const removeCommand = `npm remove ${packageName}`;
try {
await executeCommand(removeCommand);
} catch (_) {}
} catch {}
throw new Error(RESPONSE_ERROR_MESSAGES.PACKAGE_DOES_NOT_CONTAIN_NODES);
}
@ -284,7 +284,7 @@ export class LoadNodesAndCredentials implements INodesAndCredentials {
const removeCommand = `npm remove ${packageName}`;
try {
await executeCommand(removeCommand);
} catch (_) {}
} catch {}
throw new Error(RESPONSE_ERROR_MESSAGES.PACKAGE_DOES_NOT_CONTAIN_NODES);
}
}
@ -418,7 +418,7 @@ export class LoadNodesAndCredentials implements INodesAndCredentials {
await fsAccess(checkPath);
// Folder exists, so use it.
return path.dirname(checkPath);
} catch (_) {} // Folder does not exist so get next one
} catch {} // Folder does not exist so get next one
}
throw new Error('Could not find "node_modules" folder!');
}

View File

@ -16,7 +16,7 @@ export const validCredentialType = (
): express.Response | void => {
try {
Container.get(CredentialTypes).getByName(req.body.type);
} catch (_) {
} catch {
return res.status(400).json({ message: 'req.body.type is not a known type' });
}

View File

@ -202,7 +202,7 @@ nodesController.get(
if (missingPackages) {
hydratedPackages = matchMissingPackages(hydratedPackages, missingPackages);
}
} catch (_) {
} catch {
// Do nothing if setting is missing
}

View File

@ -44,7 +44,7 @@ export class TranslationController {
async getNodeTranslationHeaders() {
try {
await access(`${NODE_HEADERS_PATH}.js`);
} catch (_) {
} catch {
return; // no headers available
}

View File

@ -69,7 +69,7 @@ function makeUpdateParams(fetchedWorkflows: PinData.FetchedWorkflow[]) {
if (typeof rawPinData === 'string') {
try {
pinDataPerWorkflow = JSON.parse(rawPinData);
} catch (_) {
} catch {
pinDataPerWorkflow = {};
}
} else {

View File

@ -132,7 +132,7 @@ export class MessageEventBusDestinationWebhook
let encryptionKey: string | undefined;
try {
encryptionKey = await UserSettings.getEncryptionKey();
} catch (_) {}
} catch {}
if (encryptionKey) {
this.credentialsHelper = new CredentialsHelper(encryptionKey);
}
@ -189,7 +189,7 @@ export class MessageEventBusDestinationWebhook
// query is specified using JSON
try {
JSON.parse(this.jsonQuery);
} catch (_) {
} catch {
console.log('JSON parameter need to be an valid JSON');
}
this.axiosRequestOptions.params = jsonParse(this.jsonQuery);
@ -207,7 +207,7 @@ export class MessageEventBusDestinationWebhook
// body is specified using JSON
try {
JSON.parse(this.jsonHeaders);
} catch (_) {
} catch {
console.log('JSON parameter need to be an valid JSON');
}
this.axiosRequestOptions.headers = jsonParse(this.jsonHeaders);
@ -302,27 +302,27 @@ export class MessageEventBusDestinationWebhook
if (this.genericAuthType === 'httpBasicAuth') {
try {
httpBasicAuth = await this.matchDecryptedCredentialType('httpBasicAuth');
} catch (_) {}
} catch {}
} else if (this.genericAuthType === 'httpDigestAuth') {
try {
httpDigestAuth = await this.matchDecryptedCredentialType('httpDigestAuth');
} catch (_) {}
} catch {}
} else if (this.genericAuthType === 'httpHeaderAuth') {
try {
httpHeaderAuth = await this.matchDecryptedCredentialType('httpHeaderAuth');
} catch (_) {}
} catch {}
} else if (this.genericAuthType === 'httpQueryAuth') {
try {
httpQueryAuth = await this.matchDecryptedCredentialType('httpQueryAuth');
} catch (_) {}
} catch {}
} else if (this.genericAuthType === 'oAuth1Api') {
try {
oAuth1Api = await this.matchDecryptedCredentialType('oAuth1Api');
} catch (_) {}
} catch {}
} else if (this.genericAuthType === 'oAuth2Api') {
try {
oAuth2Api = await this.matchDecryptedCredentialType('oAuth2Api');
} catch (_) {}
} catch {}
}
}

View File

@ -233,7 +233,7 @@ export abstract class DirectoryLoader {
}
node.description.codex = codex;
} catch (_) {
} catch {
Logger.debug(`No codex available for: ${filePath.split('/').pop() ?? ''}`);
if (isCustom) {

View File

@ -129,7 +129,7 @@ export default mixins(linterExtension, completerExtension, workflowHelpers).exte
context,
inserted_text: insertedText,
});
} catch (_) {}
} catch {}
},
},
destroyed() {

View File

@ -84,7 +84,7 @@ export const completerExtension = mixins(
try {
variablesToValues = this.variablesToValues();
} catch (_) {
} catch {
return null;
}

View File

@ -220,7 +220,7 @@ export const jsonFieldCompletions = (Vue as CodeNodeEditorMixin).extend({
return input.main[0][0].node;
}
} catch (_) {
} catch {
return null;
}
},
@ -291,7 +291,7 @@ export const jsonFieldCompletions = (Vue as CodeNodeEditorMixin).extend({
}
return nodePinData[itemIndex].json;
} catch (_) {}
} catch {}
}
const runData: IRunData | null = this.workflowsStore.getWorkflowRunData;
@ -309,7 +309,7 @@ export const jsonFieldCompletions = (Vue as CodeNodeEditorMixin).extend({
}
return nodeRunData[0].data!.main[0]![itemIndex].json;
} catch (_) {
} catch {
return null;
}
},

View File

@ -35,7 +35,7 @@ export const linterExtension = (Vue as CodeNodeEditorMixin).extend({
// optional chaining operators currently unsupported by esprima-next
if (['?.', ']?'].some((operator) => lineAtError.includes(operator))) return [];
} catch (_) {
} catch {
return [];
}
@ -50,7 +50,7 @@ export const linterExtension = (Vue as CodeNodeEditorMixin).extend({
message: this.$locale.baseText('codeNodeEditor.linter.bothModes.syntaxError'),
},
];
} catch (_) {
} catch {
/**
* For invalid (e.g. half-written) n8n syntax, esprima errors with an off-by-one line number for the final line. In future, we should add full linting for n8n syntax before parsing JS.
*/

View File

@ -484,7 +484,7 @@ export default mixins(externalHooks, nodeHelpers).extend({
});
this.uiStore.setHttpNodeParameters({ name: IMPORT_CURL_MODAL_KEY, parameters: '' });
} catch (_) {}
} catch {}
}
},
},

View File

@ -32,7 +32,7 @@ export function bracketAccessCompletions(context: CompletionContext): Completion
try {
resolved = resolveParameter(`={{ ${base} }}`);
} catch (_) {
} catch {
return null;
}

View File

@ -44,7 +44,7 @@ export function datatypeCompletions(context: CompletionContext): CompletionResul
try {
resolved = resolveParameter(`={{ ${base} }}`);
} catch (_) {
} catch {
return null;
}
@ -52,7 +52,7 @@ export function datatypeCompletions(context: CompletionContext): CompletionResul
try {
options = datatypeOptions(resolved, base).map(stripExcessParens(context));
} catch (_) {
} catch {
return null;
}
}

View File

@ -611,22 +611,22 @@ export class HttpRequestV1 implements INodeType {
try {
httpBasicAuth = await this.getCredentials('httpBasicAuth');
} catch (_) {}
} catch {}
try {
httpDigestAuth = await this.getCredentials('httpDigestAuth');
} catch (_) {}
} catch {}
try {
httpHeaderAuth = await this.getCredentials('httpHeaderAuth');
} catch (_) {}
} catch {}
try {
httpQueryAuth = await this.getCredentials('httpQueryAuth');
} catch (_) {}
} catch {}
try {
oAuth1Api = await this.getCredentials('oAuth1Api');
} catch (_) {}
} catch {}
try {
oAuth2Api = await this.getCredentials('oAuth2Api');
} catch (_) {}
} catch {}
let requestOptions: OptionsWithUri;
let setUiParameter: IDataObject;

View File

@ -621,7 +621,7 @@ export class HttpRequestV2 implements INodeType {
| 'predefinedCredentialType'
| 'genericCredentialType'
| 'none';
} catch (_) {}
} catch {}
let httpBasicAuth;
let httpDigestAuth;
@ -637,32 +637,32 @@ export class HttpRequestV2 implements INodeType {
if (genericAuthType === 'httpBasicAuth') {
try {
httpBasicAuth = await this.getCredentials('httpBasicAuth');
} catch (_) {}
} catch {}
} else if (genericAuthType === 'httpDigestAuth') {
try {
httpDigestAuth = await this.getCredentials('httpDigestAuth');
} catch (_) {}
} catch {}
} else if (genericAuthType === 'httpHeaderAuth') {
try {
httpHeaderAuth = await this.getCredentials('httpHeaderAuth');
} catch (_) {}
} catch {}
} else if (genericAuthType === 'httpQueryAuth') {
try {
httpQueryAuth = await this.getCredentials('httpQueryAuth');
} catch (_) {}
} catch {}
} else if (genericAuthType === 'oAuth1Api') {
try {
oAuth1Api = await this.getCredentials('oAuth1Api');
} catch (_) {}
} catch {}
} else if (genericAuthType === 'oAuth2Api') {
try {
oAuth2Api = await this.getCredentials('oAuth2Api');
} catch (_) {}
} catch {}
}
} else if (authentication === 'predefinedCredentialType') {
try {
nodeCredentialType = this.getNodeParameter('nodeCredentialType', 0) as string;
} catch (_) {}
} catch {}
}
let requestOptions: OptionsWithUri;

View File

@ -888,7 +888,7 @@ export class HttpRequestV3 implements INodeType {
| 'predefinedCredentialType'
| 'genericCredentialType'
| 'none';
} catch (_) {}
} catch {}
let httpBasicAuth;
let httpDigestAuth;
@ -904,32 +904,32 @@ export class HttpRequestV3 implements INodeType {
if (genericAuthType === 'httpBasicAuth') {
try {
httpBasicAuth = await this.getCredentials('httpBasicAuth');
} catch (_) {}
} catch {}
} else if (genericAuthType === 'httpDigestAuth') {
try {
httpDigestAuth = await this.getCredentials('httpDigestAuth');
} catch (_) {}
} catch {}
} else if (genericAuthType === 'httpHeaderAuth') {
try {
httpHeaderAuth = await this.getCredentials('httpHeaderAuth');
} catch (_) {}
} catch {}
} else if (genericAuthType === 'httpQueryAuth') {
try {
httpQueryAuth = await this.getCredentials('httpQueryAuth');
} catch (_) {}
} catch {}
} else if (genericAuthType === 'oAuth1Api') {
try {
oAuth1Api = await this.getCredentials('oAuth1Api');
} catch (_) {}
} catch {}
} else if (genericAuthType === 'oAuth2Api') {
try {
oAuth2Api = await this.getCredentials('oAuth2Api');
} catch (_) {}
} catch {}
}
} else if (authentication === 'predefinedCredentialType') {
try {
nodeCredentialType = this.getNodeParameter('nodeCredentialType', 0) as string;
} catch (_) {}
} catch {}
}
let requestOptions: OptionsWithUri = {
@ -1110,7 +1110,7 @@ export class HttpRequestV3 implements INodeType {
if (typeof jsonBodyParameter !== 'object' && jsonBodyParameter !== null) {
try {
JSON.parse(jsonBodyParameter);
} catch (_) {
} catch {
throw new NodeOperationError(
this.getNode(),
'JSON parameter need to be an valid JSON',
@ -1163,7 +1163,7 @@ export class HttpRequestV3 implements INodeType {
// query is specified using JSON
try {
JSON.parse(jsonQueryParameter);
} catch (_) {
} catch {
throw new NodeOperationError(
this.getNode(),
'JSON parameter need to be an valid JSON',
@ -1188,7 +1188,7 @@ export class HttpRequestV3 implements INodeType {
// body is specified using JSON
try {
JSON.parse(jsonHeadersParameter);
} catch (_) {
} catch {
throw new NodeOperationError(
this.getNode(),
'JSON parameter need to be an valid JSON',

View File

@ -64,7 +64,7 @@ export function getDomainBase(raw: string, urlParts = URL_PARTS_REGEX): string {
const url = new URL(raw);
return [url.protocol, url.hostname].join('//');
} catch (_) {
} catch {
const match = urlParts.exec(raw);
if (!match?.groups?.protocolPlusDomain) return '';
@ -98,7 +98,7 @@ export function getDomainPath(raw: string, urlParts = URL_PARTS_REGEX): string {
if (!url.hostname) throw new Error('Malformed URL');
return sanitizeRoute(url.pathname);
} catch (_) {
} catch {
const match = urlParts.exec(raw);
if (!match?.groups?.pathname) return '';
@ -168,7 +168,7 @@ export function generateNodesGraph(
if (node.type === 'n8n-nodes-base.httpRequest' && node.typeVersion === 1) {
try {
nodeItem.domain = new URL(node.parameters.url as string).hostname;
} catch (_) {
} catch {
nodeItem.domain = getDomainBase(node.parameters.url as string);
}
} else if (node.type === 'n8n-nodes-base.httpRequest' && [2, 3].includes(node.typeVersion)) {