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

[DOCS] Documentation for FieldError exception #54842

Merged
merged 1 commit into from
Jun 20, 2024

Conversation

arhik
Copy link
Contributor

@arhik arhik commented Jun 18, 2024

FieldError was introduced in #54504. This PR adds documentation for the same.

Fixes #54830

@arhik arhik force-pushed the FIeldErrorDocs branch 3 times, most recently from 93d2cec to e23a310 Compare June 18, 2024 04:27
base/docs/basedocs.jl Outdated Show resolved Hide resolved
@arhik arhik force-pushed the FIeldErrorDocs branch 2 times, most recently from 0f0b91c to 60c623f Compare June 19, 2024 02:23
@nsajko nsajko added the docs This change adds or pertains to documentation label Jun 19, 2024
@arhik arhik requested a review from nsajko June 20, 2024 05:41
@arhik
Copy link
Contributor Author

arhik commented Jun 20, 2024

@LilithHafner Added docs for Fielderror. Above test failures are unrelated I think. Would you kindly take a look at this too? This will be final closure for FieldError related PRs if this is merged. Thank you for guiding me on this.

@nsajko
Copy link
Contributor

nsajko commented Jun 20, 2024

Is user code allowed/encouraged to throw FieldError, or is it better to leave it to getfield to throw this exception?

@arhik
Copy link
Contributor Author

arhik commented Jun 20, 2024

User code wouldn't need to throw FieldError, but can capture FieldError to add error hints to custom DataType and structs. User code should leave the default case of not finding the field to getfield.

But for internal use cases FieldError might find its use in limiting an access to a field (private/public field access control mechanism for instance).

User can still raise FieldError (not encouraged), if there is a rare case you would want to do that. Wrapped exception is more apt approach for such cases rather. In any case it is allowed with current infrastructure.

Comment on lines 1640 to 1643

!!! compat "Julia 1.12"
ErrorException should no longer be used to raise exceptions for invalid field access. Use FieldError instead.

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
!!! compat "Julia 1.12"
ErrorException should no longer be used to raise exceptions for invalid field access. Use FieldError instead.

This compat annotation belongs in the FieldError docstring

base/docs/basedocs.jl Show resolved Hide resolved
base/docs/basedocs.jl Show resolved Hide resolved
FieldError was introduced in JuliaLang#54504. This PR adds documentation for the same.

add types to signature in docs

Co-Authored-By: Neven Sajko <[email protected]>
Co-authored-by: Lilith Orion Hafner <[email protected]>
@LilithHafner
Copy link
Member

Thanks!

@LilithHafner LilithHafner merged commit 807055a into JuliaLang:master Jun 20, 2024
4 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This change adds or pertains to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

document FieldError
3 participants