forked from gstotts/insightcloudsec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.go
37 lines (30 loc) · 1.02 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
31
32
33
34
35
36
37
package insightcloudsec
import (
"fmt"
"net/http"
)
// MissingConfigError is a type of error raised by create a client without required config elements
type MissingConfigError struct {
MissingItem string
Details string
}
func (e MissingConfigError) Error() string {
return fmt.Sprintf("\nError:\nMissing configuration item: %s\n%s", e.MissingItem, e.Details)
}
// APIRequestError is a type of error raised by API calls made from this library
type APIRequestError struct {
Request http.Request
StatusCode int
Message string
}
func (e APIRequestError) Error() string {
return fmt.Sprintf("\nRequested URL: %s\nHTTP Status: %d: %s\n", e.Request.URL, e.StatusCode, e.Message)
}
// ValidationError is a type of error raised when validation of a given string is not of an expected/required value
type ValidationError struct {
ItemToValidate string
ExpectedValues []string
}
func (e ValidationError) Error() string {
return fmt.Sprintf("\n Validation Error: %s should be one of %s", e.ItemToValidate, e.ExpectedValues)
}