mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-15 19:22:46 -06:00
6fe2703665
* Remove `make updatedeps` from Travis build. We'll follow up with more specific plans around dependency updating in subsequent PRs. * Update all `make` targets to set `GO15VENDOREXPERIMENT=1` and to filter out `/vendor/` from `./...` where appropriate. * Temporarily remove `vet` from the `make test` target until we can figure out how to get it to not vet `vendor/`. (Initial experimentation failed to yield the proper incantation.) Everything is pinned to current master, with the exception of: * Azure/azure-sdk-for-go which is pinned before the breaking change today * aws/aws-sdk-go which is pinned to the most recent tag The documentation still needs to be updated, which we can do in a follow up PR. The goal here is to unblock release.
81 lines
1.7 KiB
Go
81 lines
1.7 KiB
Go
package statuscake
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
// APIError implements the error interface an it's used when the API response has errors.
|
|
type APIError interface {
|
|
APIError() string
|
|
}
|
|
|
|
type httpError struct {
|
|
status string
|
|
statusCode int
|
|
}
|
|
|
|
func (e *httpError) Error() string {
|
|
return fmt.Sprintf("HTTP error: %d - %s", e.statusCode, e.status)
|
|
}
|
|
|
|
// ValidationError is a map where the key is the invalid field and the value is a message describing why the field is invalid.
|
|
type ValidationError map[string]string
|
|
|
|
func (e ValidationError) Error() string {
|
|
var messages []string
|
|
|
|
for k, v := range e {
|
|
m := fmt.Sprintf("%s %s", k, v)
|
|
messages = append(messages, m)
|
|
}
|
|
|
|
return strings.Join(messages, ", ")
|
|
}
|
|
|
|
type updateError struct {
|
|
Issues interface{}
|
|
}
|
|
|
|
func (e *updateError) Error() string {
|
|
var messages []string
|
|
|
|
if issues, ok := e.Issues.(map[string]interface{}); ok {
|
|
for k, v := range issues {
|
|
m := fmt.Sprintf("%s %s", k, v)
|
|
messages = append(messages, m)
|
|
}
|
|
} else if issues, ok := e.Issues.([]interface{}); ok {
|
|
for _, v := range issues {
|
|
m := fmt.Sprint(v)
|
|
messages = append(messages, m)
|
|
}
|
|
}
|
|
|
|
return strings.Join(messages, ", ")
|
|
}
|
|
|
|
// APIError returns the error specified in the API response
|
|
func (e *updateError) APIError() string {
|
|
return e.Error()
|
|
}
|
|
|
|
type deleteError struct {
|
|
Message string
|
|
}
|
|
|
|
func (e *deleteError) Error() string {
|
|
return e.Message
|
|
}
|
|
|
|
// AuthenticationError implements the error interface and it's returned
|
|
// when API responses have authentication errors
|
|
type AuthenticationError struct {
|
|
errNo int
|
|
message string
|
|
}
|
|
|
|
func (e *AuthenticationError) Error() string {
|
|
return fmt.Sprintf("%d, %s", e.errNo, e.message)
|
|
}
|