-
-
Notifications
You must be signed in to change notification settings - Fork 236
Improve error.message
#705
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
Conversation
@@ -55,8 +64,8 @@ export const makeError = ({ | |||
const isError = Object.prototype.toString.call(error) === '[object Error]'; | |||
const shortMessage = isError ? `${execaMessage}\n${error.message}` : execaMessage; | |||
const message = [shortMessage, stdio[2], stdio[1], ...stdio.slice(3)] | |||
.map(messagePart => stripFinalNewline(serializeMessagePart(messagePart))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are joining each part with newlines. If a part ends with a newline, it just results in a single newline, not two.
lib/error.js
Outdated
.filter(Boolean) | ||
.map(messagePart => serializeMessagePart(messagePart)) | ||
.join('\n'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder whether we should separate the error message, stdout and stderr with an empty line or not?
Error: this failed
stdout
...
stderr
...
vs (current behavior)
Error: this failed
stdout
...
stderr
...
The first separates each part in a clearer way. But the second one is more compact. 🤔
Which one do you prefer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 👍
a3b92d2
to
2f68220
Compare
@@ -54,10 +63,11 @@ export const makeError = ({ | |||
const execaMessage = `Command ${prefix}: ${command}`; | |||
const isError = Object.prototype.toString.call(error) === '[object Error]'; | |||
const shortMessage = isError ? `${execaMessage}\n${error.message}` : execaMessage; | |||
const message = [shortMessage, stdio[2], stdio[1], ...stdio.slice(3)] | |||
const messageStdio = all === undefined ? [stdio[2], stdio[1]] : [all]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have just added this line too: if all: true
is used, the error message should show result.all
instead, since it is intertwined, so it is more useful for debugging that splitting stdout
and stderr
.
This PR slightly improves how
error.message
is built. It also improves the related tests.