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

Clearer errors when decoding to invalid types #332

Merged
merged 1 commit into from
Nov 25, 2021
Merged

Clearer errors when decoding to invalid types #332

merged 1 commit into from
Nov 25, 2021

Commits on Nov 25, 2021

  1. Clearer errors when decoding to invalid types

    When passing an invalid type such as "int" you would get the rather
    unhelpful message of:
    
    	toml: cannot load TOML value of type map[string]interface {} into a Go integer
    
    This adds an extra check for that, so that you get:
    
    	toml: cannot decode to type int
    
    The second case is when you're using a wrong map type or struct field
    type, the previous error message was:
    
    	toml: cannot load TOML value of type bool into a Go integer
    
    So what exactly failed? No clue at all. This adds the TOML key:
    
    	toml: incompatible types: TOML key "F" has type bool; destination has type integer
    
    Also clarify the errors for non-pointers and nil a wee bit while I'm
    here.
    
    Fixes #158
    arp242 committed Nov 25, 2021
    Configuration menu
    Copy the full SHA
    43a5120 View commit details
    Browse the repository at this point in the history