Last active
January 3, 2017 20:26
-
-
Save willis7/0ed2da40ccdd91b6dfbcb4a8241f793e to your computer and use it in GitHub Desktop.
An example, the json package specifies a SyntaxError type that the json.Decode function returns when it encounters a syntax error parsing a JSON blob.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if err := dec.Decode(&val); err != nil { | |
if serr, ok := err.(*json.SyntaxError); ok { | |
line, col := findLine(f, serr.Offset) | |
return fmt.Errorf("%s:%d:%d: %v", f.Name(), line, col, err) | |
} | |
return err | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment