mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 04:04:06 -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;
|
||||
}
|
||||
|
||||
const { NODE_ENV } = process.env;
|
||||
const inDevelopment = !NODE_ENV || NODE_ENV === 'development';
|
||||
|
||||
const instance: ErrorReporter = {
|
||||
report: (error) => {
|
||||
if (error instanceof Error) {
|
||||
let e = error;
|
||||
do {
|
||||
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;
|
||||
} while (e);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue