Skip to content

Commit

Permalink
refactor(core): Display stack trace in error reporter (no-changelog) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ivov authored and cstuncsik committed Jul 31, 2024
1 parent f465837 commit 7474fcd
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/workflow/src/ErrorReporterProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 7474fcd

Please sign in to comment.