Improve error messages when reference resolution fails #72
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.
To improve the error messages for reference resolution failure, we add a
Vec<String>
to track the current parameter key for which we're resolving references into theResolveState
struct.We also extract the error rendering in
Token::resolve()
into methods onResolveState
, since we mostly need data fromResolveState
to render the error messages.The new error messages all print the parameter key for which we're resolving references. If applicable, the error messages also contain the full reference, and the particular key for which resolution failed.
To reduce repetition for the error handling, we also refactor
Token::resolve()
to always either interpolate or copy the Value which is the base for the key lookup. While this introduces a bunch of unnecessary calls toclone()
if we're not doing a lookup into aValue::String
orValue::ValueList
, the performance impact is negligible, and the resulting code is much less convoluted.Resolves #69
Checklist
bug
,enhancement
,documentation
,change
,breaking
,dependency
,internal
as they show up in the changelog