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

hcl: More helpful error messages in Index and GetAttr #474

Merged
merged 1 commit into from
Jun 25, 2021

Conversation

apparentlymart
Copy link
Member

When we first implemented these helpers we tried to anticipate a few situations that seemed likely to come up and implement specialized error messages for them, but in the intervening years we've seen a number of other situations crop up with some regularity.

Given that, I've added a few more specialized error message cases to both of these functions, so we'll return the most generic error messages in fewer situations.

Because hcl.Index and hcl.GetAttr are quite general functions used for lots of different application-specific purposes alongside their part in the implementation of the index and attribute access operators, I've intentionally kept these messages quite vague in the suggestions they make, which does mean that unfortunately users will probably need to do some further research to find a suitable resolution to these messages. Hopefully the extra context at least gives the user a better hook for that further research.

Later we could consider putting some pre-checks in the actual operator implementations that would catch some of these prior to calling the generic functions and return a more directly-prescriptive error message which assumes we're in an expression evaluation context, but I'd like to see how these new messages are received in practice first, to see if that additional complexity would be warranted.

When we first implemented these helpers we tried to anticipate a few
situations that seemed likely to come up and implement specialized error
messages for them, but in the intervening years we've seen a number of
other situations crop up with some regularity.

Given that, I've added a few more specialized error message cases to both
of these functions, so we'll return the most generic error messages in
fewer situations.

Because hcl.Index and hcl.GetAttr are quite general functions used for
lots of different application-specific purposes alongside their part in
the implementation of the index and attribute access operators, I've
intentionally kept these messages quite vague in the suggestions they
make, which does mean that unfortunately users will probably need to do
some further research to find a suitable resolution to these messages.
Hopefully the extra context at least gives the user a better hook for that
further research.

Later we could consider putting some pre-checks in the actual operator
implementations that would catch some of these prior to calling the
generic functions and return a more directly-prescriptive error message
which assumes we're in an expression evaluation context, but I'd like to
see how these new messages are received in practice first, to see if that
additional complexity would be warranted.
@apparentlymart apparentlymart added enhancement core v2 Relates to the v2 line of releases labels Jun 24, 2021
@apparentlymart apparentlymart requested a review from a team June 24, 2021 23:35
@apparentlymart apparentlymart self-assigned this Jun 24, 2021
Copy link
Contributor

@mildwonkey mildwonkey left a comment

Choose a reason for hiding this comment

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

lovely!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core enhancement v2 Relates to the v2 line of releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants