Skip to content

Instantly share code, notes, and snippets.

@tomtsang
Created February 11, 2018 14:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomtsang/2b7ac04a31a56e4071e231c49df96e76 to your computer and use it in GitHub Desktop.
Save tomtsang/2b7ac04a31a56e4071e231c49df96e76 to your computer and use it in GitHub Desktop.
error-type.go
type SyntaxError struct {
msg string // description of error
// error occurred after reading Offset bytes, from which line and columnnr can be obtained
Offset int64
}
func (e *SyntaxError) String() string { return e.msg }
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)
}
package net
type Error interface {
Timeout() bool // Is the error a timeout?
Temporary() bool // Is the error temporary?
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment