improve debug experience for MergedConfig #8
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.
On a couple occasions while debugging my metal driver, I've been perplexed by errors such as:
The root of this is bad code on my end where, for example, I think I have a normal hash but I really have a MergedConfig and calling merge(some_hash) results in an error like the one above. I spend several moments trying to figure out where I am passing in the wrong number of args and then after looking at the stack more carefully, I open up merged_config.rb to realize this is a side effect of my error.
This PR tries to make the initial error more clear.
Also, when debugging, I also run into situations where I have stuck in code like:
I know...I know terrible debugging technique but I'm a ruby noob and sometimes this is what I do.
This tells me something rather unhelpful:
This PR changes the string representation of MergedConfig to use its to_hash and then return the to_s of that hash. This helps me to see what the merge_config is holding.