chore(core): Better debug logs for local dev (#11096)

This commit is contained in:
Iván Ovejero
2024-10-07 16:57:06 +02:00
committed by GitHub
parent 19fb728da0
commit 4c7caf734c
2 changed files with 52 additions and 19 deletions

View File

@@ -5,17 +5,13 @@ 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;
if (inDevelopment) console.log(e, meta);
else Logger.error(`${e.constructor.name}: ${e.message}`, meta);
Logger.error(`${e.constructor.name}: ${e.message}`, meta);
e = e.cause as Error;
} while (e);
}