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&notification_uuid=4b50a5da-6ae9-472e-9658-984cca824762&project=4503924908883968&referrer=slack).
This commit is contained in:
Iván Ovejero
2023-09-22 11:48:20 +02:00
committed by GitHub
parent c0df5cdfd4
commit e8e44f6b6e
7 changed files with 54 additions and 12 deletions

View 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;
};
};