Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not treat errors without a stack as errors #30

Merged
merged 1 commit into from Sep 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions index.js
Expand Up @@ -159,8 +159,8 @@ module.exports = function prettyFactory (options) {

line += EOL

if (log.type === 'Error') {
const stack = log.stack ? log.stack : String(log.stack)
if (log.type === 'Error' && log.stack) {
const stack = log.stack
line += IDENT + joinLinesWithIndentation(stack) + EOL

let propsForPrint
Expand Down
7 changes: 5 additions & 2 deletions test/error-objects.test.js
Expand Up @@ -186,10 +186,12 @@ test('error like objects tests', (t) => {
})

t.test('handles errors with a null stack for Error object', (t) => {
t.plan(1)
t.plan(3)
const pretty = prettyFactory()
const expectedLines = [
' null'
' type: "Error"',
' stack: null',
' some: "property"'
]
const log = pino({}, new Writable({
write (chunk, enc, cb) {
Expand All @@ -205,6 +207,7 @@ test('error like objects tests', (t) => {

const error = Error('error message')
error.stack = null
error.some = 'property'

log.error(error)
})
Expand Down