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

Add generic Value#convert(Object) method #7076

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

jack-berg
Copy link
Member

No description provided.

@jack-berg jack-berg requested a review from a team as a code owner February 6, 2025 16:08
*
* @param object the object to convert
* @return the equivalent {@link Value}
* @throws IllegalArgumentException if not able to convert the object to {@link Value}
Copy link
Member Author

Choose a reason for hiding this comment

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

Might want to throw a checked exception to more forcibly signal to callers that they need to handle this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Decided against this:

  • This method is analagous to jackson ObjectMapper#convertValue, which only throws a runtime exception. This API is quite popular and I've used it myself without issue for years, suggesting that a runtime exception is sufficient.
  • I'm not sure what checked exception would be most appropriate to throw. Probably some subclass of IOException, and we'd probably want to introduce our own dedicated exception. In contrast, IllegalArgumentException pretty perfectly describes the error and seems appropriate to throw.

Copy link

codecov bot commented Feb 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.88%. Comparing base (ee731aa) to head (d193076).
Report is 2 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #7076      +/-   ##
============================================
+ Coverage     89.86%   89.88%   +0.01%     
- Complexity     6615     6629      +14     
============================================
  Files           740      740              
  Lines         19991    20024      +33     
  Branches       1964     1973       +9     
============================================
+ Hits          17965    17998      +33     
- Misses         1437     1438       +1     
+ Partials        589      588       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

2 participants