mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
refactor: Switch plain errors in nodes-base to ApplicationError (no-changelog) (#7914)
Ensure all errors in `nodes-base` are `ApplicationError` or children of it and contain no variables in the message, to continue normalizing all the backend errors we report to Sentry. Also, skip reporting to Sentry errors from user input and from external APIs. In future we should refine `ApplicationError` to more specific errors. Follow-up to: [#7877](https://github.com/n8n-io/n8n/pull/7877) - [x] Test workflows: https://github.com/n8n-io/n8n/actions/runs/7084627970 - [x] e2e: https://github.com/n8n-io/n8n/actions/runs/7084936861 --------- Co-authored-by: Michael Kret <michael.k@radency.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { ApplicationError } from 'n8n-workflow';
|
||||
import type {
|
||||
ITriggerFunctions,
|
||||
IDataObject,
|
||||
@@ -26,7 +27,7 @@ export function prepareNames(id: string, mode: string, additionalFields: IDataOb
|
||||
const channelName = (additionalFields.channelName as string) || `n8n_channel_${suffix}`;
|
||||
|
||||
if (channelName.includes('-')) {
|
||||
throw new Error('Channel name cannot contain hyphens (-)');
|
||||
throw new ApplicationError('Channel name cannot contain hyphens (-)', { level: 'warning' });
|
||||
}
|
||||
|
||||
return { functionName, triggerName, channelName };
|
||||
@@ -63,7 +64,7 @@ export async function pgTriggerFunction(
|
||||
const whichData = firesOn === 'DELETE' ? 'old' : 'new';
|
||||
|
||||
if (channelName.includes('-')) {
|
||||
throw new Error('Channel name cannot contain hyphens (-)');
|
||||
throw new ApplicationError('Channel name cannot contain hyphens (-)', { level: 'warning' });
|
||||
}
|
||||
|
||||
const replaceIfExists = additionalFields.replaceIfExists ?? false;
|
||||
@@ -78,7 +79,7 @@ export async function pgTriggerFunction(
|
||||
await db.any(trigger, [target, functionName, firesOn, triggerName]);
|
||||
} catch (error) {
|
||||
if ((error as Error).message.includes('near "-"')) {
|
||||
throw new Error('Names cannot contain hyphens (-)');
|
||||
throw new ApplicationError('Names cannot contain hyphens (-)', { level: 'warning' });
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
@@ -132,7 +133,7 @@ export async function searchTables(this: ILoadOptionsFunctions): Promise<INodeLi
|
||||
[schema.value],
|
||||
);
|
||||
} catch (error) {
|
||||
throw new Error(error as string);
|
||||
throw new ApplicationError(error as string);
|
||||
}
|
||||
const results: INodeListSearchItems[] = (tableList as IDataObject[]).map((s) => ({
|
||||
name: s.table_name as string,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { ApplicationError } from 'n8n-workflow';
|
||||
import type { IExecuteFunctions, IDataObject, INodeExecutionData, JsonObject } from 'n8n-workflow';
|
||||
import type pgPromise from 'pg-promise';
|
||||
import type pg from 'pg-promise/typescript/pg-subset';
|
||||
@@ -160,7 +161,9 @@ export async function pgQuery(
|
||||
return result;
|
||||
});
|
||||
}
|
||||
throw new Error('multiple, independently or transaction are valid options');
|
||||
throw new ApplicationError('multiple, independently or transaction are valid options', {
|
||||
level: 'warning',
|
||||
});
|
||||
}
|
||||
|
||||
export async function pgQueryV2(
|
||||
@@ -259,7 +262,9 @@ export async function pgQueryV2(
|
||||
return result;
|
||||
});
|
||||
}
|
||||
throw new Error('multiple, independently or transaction are valid options');
|
||||
throw new ApplicationError('multiple, independently or transaction are valid options', {
|
||||
level: 'warning',
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -348,7 +353,9 @@ export async function pgInsert(
|
||||
});
|
||||
}
|
||||
|
||||
throw new Error('multiple, independently or transaction are valid options');
|
||||
throw new ApplicationError('multiple, independently or transaction are valid options', {
|
||||
level: 'warning',
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -456,7 +463,9 @@ export async function pgInsertV2(
|
||||
});
|
||||
}
|
||||
|
||||
throw new Error('multiple, independently or transaction are valid options');
|
||||
throw new ApplicationError('multiple, independently or transaction are valid options', {
|
||||
level: 'warning',
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -582,7 +591,9 @@ export async function pgUpdate(
|
||||
});
|
||||
}
|
||||
}
|
||||
throw new Error('multiple, independently or transaction are valid options');
|
||||
throw new ApplicationError('multiple, independently or transaction are valid options', {
|
||||
level: 'warning',
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -713,5 +724,7 @@ export async function pgUpdateV2(
|
||||
});
|
||||
}
|
||||
}
|
||||
throw new Error('multiple, independently or transaction are valid options');
|
||||
throw new ApplicationError('multiple, independently or transaction are valid options', {
|
||||
level: 'warning',
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user