1 package goacmedns
2 3 import "fmt"
4 5 // ClientError represents an error from the ACME-DNS server. It holds
6 // a `Message` describing the operation the client was doing, a `HTTPStatus`
7 // code returned by the server, and the `Body` of the HTTP Response from the
8 // server.
9 type ClientError struct {
10 // Message is a string describing the client operation that failed
11 Message string
12 // HTTPStatus is the HTTP status code the ACME DNS server returned
13 HTTPStatus int
14 // Body is the response body the ACME DNS server returned
15 Body []byte
16 }
17 18 // Error collects all the ClientError fields into a single string.
19 func (e ClientError) Error() string {
20 return fmt.Sprintf("%s : status code %d response: %s",
21 e.Message, e.HTTPStatus, string(e.Body))
22 }
23 24 // newClientError creates a ClientError instance populated with the given
25 // arguments.
26 func newClientError(msg string, respCode int, respBody []byte) *ClientError {
27 return &ClientError{
28 Message: msg,
29 HTTPStatus: respCode,
30 Body: respBody,
31 }
32 }
33