Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Errors in Go are custom types; your error can be defined as, for example:

    type URLError {
        url String
    }

    func (e URLError) Error() String {
        return fmt.Sprintf("Invalid URL: %s", e.url)
    }
At which point a caller that wants to handle this error can either extract the URL to do fun things with it or just dump the Error() string.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: