Improve error handling in dev-only (#2095)

zio/stable
Eric Bailey 2023-12-05 20:23:48 -06:00 committed by GitHub
parent 570b78c32e
commit 7f3324d4a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 3 deletions

View File

@ -110,8 +110,7 @@ export const consoleTransport: Transport = (
timestamp,
) => {
const extra = Object.keys(metadata).length
? // don't prepareMetadata here, in dev we want the stack trace
' ' + JSON.stringify(metadata, null, ' ')
? ' ' + JSON.stringify(prepareMetadata(metadata), null, ' ')
: ''
const log = {
[LogLevel.Debug]: console.debug,
@ -121,7 +120,14 @@ export const consoleTransport: Transport = (
[LogLevel.Error]: console.error,
}[level]
if (message instanceof Error) {
console.info(
`${format(timestamp, 'HH:mm:ss')} ${message.toString()}${extra}`,
)
log(message)
} else {
log(`${format(timestamp, 'HH:mm:ss')} ${message.toString()}${extra}`)
}
}
export const sentryTransport: Transport = (