-
Notifications
You must be signed in to change notification settings - Fork 16
/
errors.go
30 lines (24 loc) · 1 KB
/
errors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package client
import (
"fmt"
)
// ResponseError is the error returned from the client when Key Manager responds with an error or
// non-success HTTP status code. ResponseError gives
// access to the underlying errors and status code.
type ResponseError struct {
// StatusCode is the HTTP status code.
StatusCode int `json:"statusCode,omitempty" example:"404"`
// ErrorCode is the key manager error code.
ErrorCode string `json:"code,omitempty" example:"IR001"`
// Errors are the underlying errors returned by Vault.
Message string `json:"message" example:"error message"`
}
// ErrorResponse is the raw error type returned from the key manager
type ErrorResponse struct {
Message string `json:"message" example:"error message"`
Code string `json:"code,omitempty" example:"IR001"`
}
// Error returns a human-readable error string for the response error.
func (r *ResponseError) Error() string {
return fmt.Sprintf("Error making API request.\nCode: %s. %s:\nStatus: %d.", r.ErrorCode, r.Message, r.StatusCode)
}