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