mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
refactor(core): Log binary data file write errors (no-changelog) (#7237)
This PR adds logging for binary data file write errors, to capture why executions sometimes point to non-existing binary data files. See [Sentry error](https://n8nio.sentry.io/issues/4495134693/?alert_rule_id=14556563&alert_type=issue¬ification_uuid=4b50a5da-6ae9-472e-9658-984cca824762&project=4503924908883968&referrer=slack).
This commit is contained in:
30
packages/core/src/decorators/LogCatch.decorator.ts
Normal file
30
packages/core/src/decorators/LogCatch.decorator.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||
|
||||
export const LogCatch = (logFn: (error: unknown) => void) => {
|
||||
return (target: unknown, propertyKey: string, descriptor: PropertyDescriptor) => {
|
||||
const originalMethod = descriptor.value;
|
||||
|
||||
descriptor.value = function (...args: unknown[]) {
|
||||
try {
|
||||
const result: unknown = originalMethod.apply(this, args);
|
||||
|
||||
if (result && result instanceof Promise) {
|
||||
return result.catch((error: unknown) => {
|
||||
logFn(error);
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
} catch (error) {
|
||||
logFn(error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
return descriptor;
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user