mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-11 21:07:28 -08:00
refactor(core): Display stack trace in error reporter (no-changelog) (#10225)
This commit is contained in:
parent
1a7713ef26
commit
de50ef7590
|
@ -5,13 +5,17 @@ interface ErrorReporter {
|
||||||
report: (error: Error | string, options?: ReportingOptions) => void;
|
report: (error: Error | string, options?: ReportingOptions) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const { NODE_ENV } = process.env;
|
||||||
|
const inDevelopment = !NODE_ENV || NODE_ENV === 'development';
|
||||||
|
|
||||||
const instance: ErrorReporter = {
|
const instance: ErrorReporter = {
|
||||||
report: (error) => {
|
report: (error) => {
|
||||||
if (error instanceof Error) {
|
if (error instanceof Error) {
|
||||||
let e = error;
|
let e = error;
|
||||||
do {
|
do {
|
||||||
const meta = e instanceof ApplicationError ? e.extra : undefined;
|
const meta = e instanceof ApplicationError ? e.extra : undefined;
|
||||||
Logger.error(`${e.constructor.name}: ${e.message}`, meta);
|
if (inDevelopment) console.log(e, meta);
|
||||||
|
else Logger.error(`${e.constructor.name}: ${e.message}`, meta);
|
||||||
e = e.cause as Error;
|
e = e.cause as Error;
|
||||||
} while (e);
|
} while (e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue