mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
feat(core): Explicitly report external hook failures (#12830)
This commit is contained in:
parent
02880cc5a6
commit
a24e4420bb
|
@ -1,5 +1,6 @@
|
|||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
import { Service } from '@n8n/di';
|
||||
import { ErrorReporter } from 'n8n-core';
|
||||
import { ApplicationError } from 'n8n-workflow';
|
||||
|
||||
import config from '@/config';
|
||||
|
@ -20,6 +21,7 @@ export class ExternalHooks {
|
|||
private dbCollections: IExternalHooksFunctions['dbCollections'];
|
||||
|
||||
constructor(
|
||||
private readonly errorReporter: ErrorReporter,
|
||||
userRepository: UserRepository,
|
||||
settingsRepository: SettingsRepository,
|
||||
credentialsRepository: CredentialsRepository,
|
||||
|
@ -94,7 +96,14 @@ export class ExternalHooks {
|
|||
};
|
||||
|
||||
for (const externalHookFunction of this.externalHooks[hookName]) {
|
||||
await externalHookFunction.apply(externalHookFunctions, hookParameters);
|
||||
try {
|
||||
await externalHookFunction.apply(externalHookFunctions, hookParameters);
|
||||
} catch (cause) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
const error = new ApplicationError(`External hook "${hookName}" failed`, { cause });
|
||||
this.errorReporter.error(error, { level: 'fatal' });
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue