-
Notifications
You must be signed in to change notification settings - Fork 15
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
Non global error handling #75
base: main
Are you sure you want to change the base?
Conversation
The irony is that I refactored error handling to be global not too long ago: 0b71b67 The thing is, passing around error objects simply became too annoying. Yes, it's not too hard to have them in the parseXXX functions, but passing them into helper functions, utility functions, other parts of the code... it just became too much to think about - logging a simple error shouldn't have such a big overhead. |
Oh, I missed that. Imo we definitely need everything to be none global though long-term. The solution might be in a combination of throwing real errors and adding parse errors. As throws will have the right context. It is two changes:
|
So, There were a few reasons that I ended up not liking non-global error handling:
The TL;DR is, we want to throw errors everywhere in our project. That means that non-global error throwing will add an extra argument to practically every function argument list we have. That's a high readability price to pay. I see your point about having parallel test runners. However, I think we can find a compromise! Obviously, the above isn't anything that has to go into this diff right now. :) |
Sure, we could try to link back errors to a project by essentially registering that project on some global error handler and then passing in nodes. But I don't see right now, where we would need to add that. So what is left (if I am correct) is error handling for non-parse stuff. |
Move the error handling to a class to have non-global errors.
Use them in tests and runners.
Depends on #60