Skip to content

fix: print error when internal cli error happens (more helpful than ERROR: null) #5344

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Rob--W
Copy link
Contributor

@Rob--W Rob--W commented Apr 27, 2025

PR Checklist

Overview

There have been issues where the reported error is "ERROR: null", which is very unhelpful. Here is an analysis of a specific example: #5048 (comment)

Although the trigger for that error was fixed by #5074, the unhelpfulness of "ERROR: null" was not addressed.

To help with debugging, this patch prints the original error when this stage is unexpectedly reached.

There have been issues where the reported error is "ERROR: null", which
is very unhelpful. Here is an analysis of a specific example:
mochajs#5048 (comment)

Although the trigger for that error was fixed by mochajs#5074, the
unhelpfulness of "ERROR: null" was not addressed.

To help with debugging, this patch prints the original error when this
stage is unexpectedly reached.
Copy link

linux-foundation-easycla bot commented Apr 27, 2025

CLA Signed


The committers listed above are authorized under a signed CLA.

@JoshuaKGoldberg
Copy link
Member

Switching to draft pending #5078 (comment). We can't review without a reproduction, and it might be that all buggy behavior was already fixed?

Thanks for the PR in the interim though!

@Rob--W
Copy link
Contributor Author

Rob--W commented May 1, 2025

Switching to draft pending #5078 (comment). We can't review without a reproduction, and it might be that all buggy behavior was already fixed?

For clarity, this is not about fixing whatever that triggered the error, but about improving the logged diagnostics information when an error (unexpectedly) happens.

While the specific trigger was fixed, it is still possible to end up in this case if some other internal error occurs. If you want to reproduce locally, you could throw an error from

console.error('\n Exception during run:', err);

There are probably other ways to trigger this issue, but I haven't looked.

If you are concerned about logging too much information (when an error message is already present), I could add a check to only log the error when the message is null.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 Bug: mocha 10.2.0 prints out command help text and ERROR: null with ts-node and experimental-specifier-resolution
2 participants