Documentation ¶
Index ¶
- Constants
- Variables
- func AppendMsg(target string, messages ...string) string
- func Equals(a, b error) bool
- func IsKnown(errorType string) bool
- func SetLogger(log *logrus.Entry)
- func SnakeToCamel(str string) string
- func TypeToSnake(t interface{}) string
- type Error
- func (e *Error) Context(name string) *Error
- func (e *Error) Error() string
- func (e *Error) HTTPStatus() int
- func (e *Error) IsParent() bool
- func (e *Error) Kind(name string) *Error
- func (e *Error) Kinds() []string
- func (e *Error) Label(name string) *Error
- func (e *Error) LogError() string
- func (e *Error) Message(msg string) *Error
- func (e *Error) Messagef(msg string, args ...interface{}) *Error
- func (e *Error) Status(s int) *Error
- func (e *Error) Unwrap() error
- func (e *Error) With(inner error) *Error
- type GoError
- type Template
Constants ¶
const HeaderErrorCode = "Couper-Error"
const Wildcard = "*"
Variables ¶
var ( AccessControl = &Error{synopsis: "access control error", kinds: []string{"access_control"}, httpStatus: http.StatusForbidden} Backend = &Error{synopsis: "backend error", Contexts: []string{"api", "endpoint"}, kinds: []string{"backend"}, httpStatus: http.StatusBadGateway} ClientRequest = &Error{synopsis: "client request error", httpStatus: http.StatusBadRequest} Endpoint = &Error{synopsis: "endpoint error", Contexts: []string{"endpoint"}, kinds: []string{"endpoint"}, httpStatus: http.StatusBadGateway} Evaluation = &Error{synopsis: "expression evaluation error", kinds: []string{"evaluation"}, httpStatus: http.StatusInternalServerError} Configuration = &Error{synopsis: "configuration error", kinds: []string{"configuration"}, httpStatus: http.StatusInternalServerError} MethodNotAllowed = &Error{synopsis: "method not allowed error", httpStatus: http.StatusMethodNotAllowed} Proxy = &Error{synopsis: "proxy error", httpStatus: http.StatusBadGateway} Request = &Error{synopsis: "request error", httpStatus: http.StatusBadGateway} RouteNotFound = &Error{synopsis: "route not found error", httpStatus: http.StatusNotFound} Server = &Error{synopsis: "internal server error", httpStatus: http.StatusInternalServerError} ServerShutdown = &Error{synopsis: "server shutdown error", httpStatus: http.StatusInternalServerError} )
var ( BasicAuth = Definitions[1] BasicAuthCredentialsMissing = Definitions[2] Jwt = Definitions[3] JwtTokenExpired = Definitions[4] JwtTokenInvalid = Definitions[5] JwtTokenMissing = Definitions[6] Oauth2 = Definitions[7] Saml2 = Definitions[8] Saml = Definitions[9] InsufficientPermissions = Definitions[10] BackendOpenapiValidation = Definitions[12] BetaBackendRateLimitExceeded = Definitions[13] BackendTimeout = Definitions[14] BetaBackendTokenRequest = Definitions[15] BackendUnhealthy = Definitions[16] Sequence = Definitions[18] UnexpectedStatus = Definitions[19] )
var Definitions = []*Error{ AccessControl, AccessControl.Kind("basic_auth").Status(http.StatusUnauthorized), AccessControl.Kind("basic_auth").Kind("basic_auth_credentials_missing").Status(http.StatusUnauthorized), AccessControl.Kind("jwt").Status(http.StatusUnauthorized), AccessControl.Kind("jwt").Kind("jwt_token_expired").Status(http.StatusUnauthorized), AccessControl.Kind("jwt").Kind("jwt_token_invalid").Status(http.StatusUnauthorized), AccessControl.Kind("jwt").Kind("jwt_token_missing").Status(http.StatusUnauthorized), AccessControl.Kind("oauth2"), AccessControl.Kind("saml2"), AccessControl.Kind("saml2").Kind("saml"), AccessControl.Kind("insufficient_permissions").Context("api").Context("endpoint"), Backend, Backend.Kind("backend_openapi_validation").Status(http.StatusBadRequest), Backend.Kind("beta_backend_rate_limit_exceeded").Status(http.StatusTooManyRequests), Backend.Kind("backend_timeout").Status(http.StatusGatewayTimeout), Backend.Kind("beta_backend_token_request"), Backend.Kind("backend_unhealthy"), Endpoint, Endpoint.Kind("sequence"), Endpoint.Kind("unexpected_status"), }
Definitions holds all implemented ones. The name must match the structs snake-name for fallback purposes. See TypeToSnake usage and reference.
var SuperTypesMapsByContext = map[string]map[string][]string{"api": map[string][]string{"*": []string{"insufficient_permissions", "backend_openapi_validation", "beta_backend_rate_limit_exceeded", "backend_timeout", "beta_backend_token_request", "backend_unhealthy"}, "access_control": []string{"insufficient_permissions"}, "backend": []string{"backend_openapi_validation", "beta_backend_rate_limit_exceeded", "backend_timeout", "beta_backend_token_request", "backend_unhealthy"}}, "endpoint": map[string][]string{"*": []string{"insufficient_permissions", "backend_openapi_validation", "beta_backend_rate_limit_exceeded", "backend_timeout", "beta_backend_token_request", "backend_unhealthy", "sequence", "unexpected_status"}, "access_control": []string{"insufficient_permissions"}, "backend": []string{"backend_openapi_validation", "beta_backend_rate_limit_exceeded", "backend_timeout", "beta_backend_token_request", "backend_unhealthy"}, "endpoint": []string{"sequence", "unexpected_status"}}}
SuperTypesMapsByContext holds maps for error super-types to sub-types by a given context block type (e.g. api or endpoint).
Functions ¶
func IsKnown ¶
IsKnown tells the configuration callee if Couper has a defined error type with the given name.
func SnakeToCamel ¶
func TypeToSnake ¶
func TypeToSnake(t interface{}) string
Types ¶
type Error ¶
type Error struct { Contexts []string // context block types (e.g. api or endpoint) // contains filtered or unexported fields }
func (*Error) HTTPStatus ¶
HTTPStatus returns the configured http status code this error should be served with.
func (*Error) Kind ¶
Kind appends the given kind name to the existing ones. Latest added should be the more specific ones.
func (*Error) Kinds ¶
Kinds returns all configured kinds, the most specific one gets evaluated first.
func (*Error) LogError ¶
LogError contains additional context which should be used for logging purposes only.
type Template ¶
type Template struct {
// contains filtered or unexported fields
}
func NewTemplate ¶
func NewTemplateFromFile ¶
func (*Template) WithContextFunc ¶
func (t *Template) WithContextFunc(fn http.HandlerFunc) *Template