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

Improve error reporting #79381

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

RenechCDDA
Copy link
Member

Summary

Infrastructure "Improve error reporting"

Purpose of change

Our errors aren't always helpful in explaining what they mean. This confuses users (who go looking for C++ source files which they don't have) and contributors (who may troubleshoot the wrong thing until they realize what's going on).

Describe the solution

Make them more helpful.

-JSON syntax errors say they are syntax errors, to help people understand how to resolve them.

-Errors which start at the beginning of an object instead of at a member or place of error explicitly say the reported line is the beginning of the object. This has confused many, many people. Hopefully with the changes it should confuse less people.

-The line and character offset of JSON errors has been made explicit, instead of requiring you to guess what the numbers mean.

-The C++ source file names/etc were made more explicit as well, which should hopefully reduce people asking "I can't find this .cpp file on my game, where is it"

Describe alternatives you've considered

The errors which point to the start of the object could be made even better. We shouldn't even show context outside of the error object. We could also try to grab the id of the object and report that explicitly, so the contributor knows exactly what object is meant.

But that seemed like it would be a lot more difficult to implement. For example the object in question might not have an id member.

Testing

Intentionally introduce some errors, trigger the errors.

before (image from community discord):
image

after:

image

image

Additional context

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Auto-requesting reviews from non-collaborators: @andrei8l

@github-actions github-actions bot added [C++] Changes (can be) made in C++. Previously named `Code` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style json-styled JSON lint passed, label assigned by github actions labels Jan 27, 2025
@RenechCDDA RenechCDDA force-pushed the improve_error_reporting branch from 466fff4 to 2928aaa Compare January 27, 2025 20:29
@github-actions github-actions bot added the astyled astyled PR, label is assigned by github actions label Jan 27, 2025
src/math_parser.cpp Outdated Show resolved Hide resolved
-JSON syntax errors say they are syntax errors, to help people understand how to resolve them.
-The line and character offset of JSON errors has been made explicit, instead of requiring you to guess what the numbers mean.
-The C++ source file names/etc were made more explicit as well, which should hopefully reduce people asking "I can't find this .cpp file on my game, where is it"
@RenechCDDA RenechCDDA force-pushed the improve_error_reporting branch from 2928aaa to a4eeeb0 Compare January 27, 2025 21:04
@GuardianDll
Copy link
Member

We apparently have an entire test suite that test errors are reported they way they are reported

@PatrikLundell
Copy link
Contributor

Unfortunately, I find your last "after" image very confusion. It talks about an object beginning at a line that marks the end of an object, with the next line starting a new one.

@RenechCDDA
Copy link
Member Author

We apparently have an entire test suite that test errors are reported they way they are reported

Mostly that the errors are thrown at all. But in this case since I'm updating the error messages I do need to update the messages in the tests as well. Not a big deal.

Unfortunately, I find your last "after" image very confusion. It talks about an object beginning at a line that marks the end of an object, with the next line starting a new one.

I don't really disagree, but the caret position was pre-existing. I could look into changing it.

@PatrikLundell
Copy link
Contributor

Or you could change the message to match the caret position.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions [C++] Changes (can be) made in C++. Previously named `Code` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style json-styled JSON lint passed, label assigned by github actions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants