mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
fix(core): Better error message in Webhook node when using the POST method
This commit is contained in:
@@ -58,3 +58,31 @@ export const separate = <T>(array: T[], test: (element: T) => boolean) => {
|
||||
|
||||
return [pass, fail];
|
||||
};
|
||||
|
||||
export const webhookNotFoundErrorMessage = (
|
||||
path: string,
|
||||
httpMethod?: string,
|
||||
webhookMethods?: string[],
|
||||
) => {
|
||||
let webhookPath = path;
|
||||
|
||||
if (httpMethod) {
|
||||
webhookPath = `${httpMethod} ${webhookPath}`;
|
||||
}
|
||||
|
||||
if (webhookMethods?.length && httpMethod) {
|
||||
let methods = '';
|
||||
|
||||
if (webhookMethods.length === 1) {
|
||||
methods = webhookMethods[0];
|
||||
} else {
|
||||
const lastMethod = webhookMethods.pop();
|
||||
|
||||
methods = `${webhookMethods.join(', ')} or ${lastMethod as string}`;
|
||||
}
|
||||
|
||||
return `This webhook is not registered for ${httpMethod} requests. Did you mean to make a ${methods} request?`;
|
||||
} else {
|
||||
return `The requested webhook "${webhookPath}" is not registered.`;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user