Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Error when JSON/YAML parsing would set property
default
in a Dynamic #700base: main
Are you sure you want to change the base?
Error when JSON/YAML parsing would set property
default
in a Dynamic #700Changes from all commits
2d25e42
792cef3
9ee33e3
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
All other error handling code in this file throws
YamlEngineException
, which is caught in the same file and translated toVmException
. Why throw a custom exception here, only to duplicate the code that translates toVmException
? (I know this was suggested in the review, but I don't see the point.)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.
YamlEngineException
doesn't feel like the right class to throw our own errors with tailored messages. I think the direction we should move here is to switch all of our own throws fromYamlEngineException
toorg.pkl.core.util.yaml.ParseException
.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.
Throwing ParseException everywhere is an improvement. But since these exceptions are implementation details and thrown and caught in the same file, introducing your own exception feels unnecessary (adds code for no benefit).
json.ParserNodes follows the same pattern: It throws org.pkl.core.util.json.ParseException, which also isn't your own exception.
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 agree that the extra class seems needlessly verbose and that we should probably move away from
YamlEngineException
s. I don't quite understandorg.pkl.core.util.json.ParseException
not being "your own exception." What do you mean by that, @translatenix?Is there any reason not to move
org.pkl.core.util.json.ParseException
up one level (intoutil
) and use it for either?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 idea is that errors coming from
ParseException
can be presented to users as-is; because they are already tailored to be presented as error messages.YamlEngineException
messages come from SnakeYAML, and should be decorated with a generic "malformed yaml" message.I think a good north star here is to not surface messages from
YamlEngineException
at all, and instead present all parse errors as our own tailored error messages. But, for now, it's helpful to have two different exception classes so we know what comes from us, and what comes from our parser library.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.
org.pkl.core.util.json.ParseException
comes from the external JSON library that was copied into Pkl's codebase. As such it's the equivalent ofYamlEngineException
.If that's what you want, having your own exception makes sense, assuming you can't throw a
VmException
to begin with. You may want to make the same change forjson/ParserNodes
.