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

fix: Error cause is not displayed #49

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 19 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@ var DOUBLE_SPACE_REGEXP = /\x20{2}/g
var NEWLINE_REGEXP = /\n/g

/* istanbul ignore next */
var defer = typeof setImmediate === 'function'
? setImmediate
: function (fn) { process.nextTick(fn.bind.apply(fn, arguments)) }
var defer =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please revert the formatting change?

typeof setImmediate === 'function'
? setImmediate
: function (fn) {
process.nextTick(fn.bind.apply(fn, arguments))
}
var isFinished = onFinished.isFinished

/**
Expand All @@ -41,20 +44,22 @@ var isFinished = onFinished.isFinished
*/

function createHtmlDocument (message) {
var body = escapeHtml(message)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting help to understand, do we really need change this? Perhaps it is already handling multiple line error message?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also just to chime in, this kind of thing is exactly why (as requested in @IamLizu's other comment) we try to avoid unnecessary formatting changes. It makes it harder to figure out what is a functional change needing attention and what is purely presentation and can be ignored.

.replace(NEWLINE_REGEXP, '<br>')
.replace(DOUBLE_SPACE_REGEXP, ' &nbsp;')
var body = escapeHtml(message).replace(NEWLINE_REGEXP, '<br>').replace(DOUBLE_SPACE_REGEXP, ' &nbsp;')

return '<!DOCTYPE html>\n' +
return (
'<!DOCTYPE html>\n' +
'<html lang="en">\n' +
'<head>\n' +
'<meta charset="utf-8">\n' +
'<title>Error</title>\n' +
'</head>\n' +
'<body>\n' +
'<pre>' + body + '</pre>\n' +
'<pre>' +
body +
'</pre>\n' +
'</body>\n' +
'</html>\n'
)
}

/**
Expand Down Expand Up @@ -175,6 +180,11 @@ function getErrorMessage (err, status, env) {
// use err.stack, which typically includes err.message
msg = err.stack

// if error cause included
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it handle nested cause? What if the cause itself has another cause? Also, perhaps it should append the stack trace of the error itself, regardless of whether the cause exists or not?

if (err.cause) {
msg += `\n[cause]: ${err.cause.stack}`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The template literal strings are the cause of the CI failures. These are not supported in the older versions of node. Ideally we can just swap these for plain strings and then we can update them when we drop older node versions with the next major.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey! fixed it. i think that should work.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I am gearing up for some travel, but I hope to loop back on this asap. Sorry things take so long sometimes, this is an entirely volunteer group so life and work usually come first. I promise we are working on it though.

}