diff options
Diffstat (limited to 'errors.go')
-rw-r--r-- | errors.go | 29 |
1 files changed, 16 insertions, 13 deletions
@@ -3,7 +3,6 @@ package acme import ( "encoding/json" "errors" - "fmt" "io/ioutil" "net/http" ) @@ -22,15 +21,15 @@ var ( // Errors var urnErrors = map[string]error{ - "badCSR": ErrBadCSR, - "badNonce": ErrBadNonce, - "connection": ErrConnection, - "dnssec": ErrDnssec, - "malformed": ErrMalformed, - "serverInternal": ErrServerInternal, - "tls": ErrTLS, - "unauthorized": ErrUnauthorized, - "unknownHost": ErrUnknownHost, + "urn:acme:error:badCSR": ErrBadCSR, + "urn:acme:error:badNonce": ErrBadNonce, + "urn:acme:error:connection": ErrConnection, + "urn:acme:error:dnssec": ErrDnssec, + "urn:acme:error:malformed": ErrMalformed, + "urn:acme:error:serverInternal": ErrServerInternal, + "urn:acme:error:tls": ErrTLS, + "urn:acme:error:unauthorized": ErrUnauthorized, + "urn:acme:error:unknownHost": ErrUnknownHost, } func handleError(r *http.Response) error { @@ -44,8 +43,12 @@ func handleError(r *http.Response) error { if err != nil { return err } - if e, ok := urnErrors["urn:acme:error"+p.Type]; ok { - return fmt.Errorf("%v: %v", e, p.Detail) + return p +} + +func (p Problem) Error() string { + if err, ok := urnErrors[p.Type]; ok { + return err.Error() + ": " + p.Detail } - return errors.New(p.Detail) + return p.Detail } |