mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
refactor: Remove usless catch blocks, and add a linting rule to prevent them (no-changelog) (#12730)
This commit is contained in:
committed by
GitHub
parent
4ee4552b0e
commit
202da76380
@@ -161,28 +161,24 @@ export function reducePayloadSizeOrThrow(
|
||||
error: Error,
|
||||
averageTokenLength = 4,
|
||||
) {
|
||||
try {
|
||||
let remainingTokensToReduce = calculateRemainingTokens(error);
|
||||
let remainingTokensToReduce = calculateRemainingTokens(error);
|
||||
|
||||
const [remaining, parentNodesTokenCount] = trimParentNodesSchema(
|
||||
payload,
|
||||
remainingTokensToReduce,
|
||||
averageTokenLength,
|
||||
);
|
||||
const [remaining, parentNodesTokenCount] = trimParentNodesSchema(
|
||||
payload,
|
||||
remainingTokensToReduce,
|
||||
averageTokenLength,
|
||||
);
|
||||
|
||||
remainingTokensToReduce = remaining;
|
||||
remainingTokensToReduce = remaining;
|
||||
|
||||
remainingTokensToReduce = trimInputSchemaProperties(
|
||||
payload,
|
||||
remainingTokensToReduce,
|
||||
averageTokenLength,
|
||||
parentNodesTokenCount,
|
||||
);
|
||||
remainingTokensToReduce = trimInputSchemaProperties(
|
||||
payload,
|
||||
remainingTokensToReduce,
|
||||
averageTokenLength,
|
||||
parentNodesTokenCount,
|
||||
);
|
||||
|
||||
if (remainingTokensToReduce > 0) throw error;
|
||||
} catch (e) {
|
||||
throw e;
|
||||
}
|
||||
if (remainingTokensToReduce > 0) throw error;
|
||||
}
|
||||
|
||||
export async function generateCodeForAiTransform(prompt: string, path: string, retries = 1) {
|
||||
|
||||
@@ -200,29 +200,25 @@ async function createExecutionPromise() {
|
||||
}
|
||||
|
||||
async function onRunChatWorkflow(payload: RunWorkflowChatPayload) {
|
||||
try {
|
||||
const runWorkflowOptions: Parameters<typeof runWorkflow>[0] = {
|
||||
triggerNode: payload.triggerNode,
|
||||
nodeData: payload.nodeData,
|
||||
source: payload.source,
|
||||
};
|
||||
const runWorkflowOptions: Parameters<typeof runWorkflow>[0] = {
|
||||
triggerNode: payload.triggerNode,
|
||||
nodeData: payload.nodeData,
|
||||
source: payload.source,
|
||||
};
|
||||
|
||||
if (workflowsStore.chatPartialExecutionDestinationNode) {
|
||||
runWorkflowOptions.destinationNode = workflowsStore.chatPartialExecutionDestinationNode;
|
||||
workflowsStore.chatPartialExecutionDestinationNode = null;
|
||||
}
|
||||
|
||||
const response = await runWorkflow(runWorkflowOptions);
|
||||
|
||||
if (response) {
|
||||
await createExecutionPromise();
|
||||
workflowsStore.appendChatMessage(payload.message);
|
||||
return response;
|
||||
}
|
||||
return;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
if (workflowsStore.chatPartialExecutionDestinationNode) {
|
||||
runWorkflowOptions.destinationNode = workflowsStore.chatPartialExecutionDestinationNode;
|
||||
workflowsStore.chatPartialExecutionDestinationNode = null;
|
||||
}
|
||||
|
||||
const response = await runWorkflow(runWorkflowOptions);
|
||||
|
||||
if (response) {
|
||||
await createExecutionPromise();
|
||||
workflowsStore.appendChatMessage(payload.message);
|
||||
return response;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Initialize chat config
|
||||
|
||||
@@ -55,21 +55,13 @@ export const useCommunityNodesStore = defineStore(STORES.COMMUNITY_NODES, () =>
|
||||
};
|
||||
|
||||
const installPackage = async (packageName: string): Promise<void> => {
|
||||
try {
|
||||
await communityNodesApi.installNewPackage(rootStore.restApiContext, packageName);
|
||||
await fetchInstalledPackages();
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
await communityNodesApi.installNewPackage(rootStore.restApiContext, packageName);
|
||||
await fetchInstalledPackages();
|
||||
};
|
||||
|
||||
const uninstallPackage = async (packageName: string): Promise<void> => {
|
||||
try {
|
||||
await communityNodesApi.uninstallPackage(rootStore.restApiContext, packageName);
|
||||
removePackageByName(packageName);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
await communityNodesApi.uninstallPackage(rootStore.restApiContext, packageName);
|
||||
removePackageByName(packageName);
|
||||
};
|
||||
|
||||
const removePackageByName = (name: string): void => {
|
||||
@@ -82,16 +74,12 @@ export const useCommunityNodesStore = defineStore(STORES.COMMUNITY_NODES, () =>
|
||||
};
|
||||
|
||||
const updatePackage = async (packageName: string): Promise<void> => {
|
||||
try {
|
||||
const packageToUpdate = installedPackages.value[packageName];
|
||||
const updatedPackage = await communityNodesApi.updatePackage(
|
||||
rootStore.restApiContext,
|
||||
packageToUpdate.packageName,
|
||||
);
|
||||
updatePackageObject(updatedPackage);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
const packageToUpdate = installedPackages.value[packageName];
|
||||
const updatedPackage = await communityNodesApi.updatePackage(
|
||||
rootStore.restApiContext,
|
||||
packageToUpdate.packageName,
|
||||
);
|
||||
updatePackageObject(updatedPackage);
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
@@ -173,8 +173,6 @@ export const useExecutionsStore = defineStore('executions', () => {
|
||||
executionsCount.value = data.count;
|
||||
executionsCountEstimated.value = data.estimated;
|
||||
return data;
|
||||
} catch (e) {
|
||||
throw e;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user