2021-05-14 15:19:02 +00:00
|
|
|
package upgrade
|
2018-05-04 06:41:40 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
)
|
2018-09-29 12:39:12 +00:00
|
|
|
|
2021-06-15 22:04:09 +00:00
|
|
|
// ErrInvalidRequest for invalid requests
|
2018-05-04 06:41:40 +00:00
|
|
|
// - multiple-value if only 1 expected
|
2021-06-15 22:04:09 +00:00
|
|
|
type ErrInvalidRequest struct {
|
2018-05-04 06:41:40 +00:00
|
|
|
Field string
|
|
|
|
Reason string
|
|
|
|
}
|
|
|
|
|
2021-06-15 22:04:09 +00:00
|
|
|
func (err ErrInvalidRequest) Error() string {
|
|
|
|
return fmt.Sprintf("invalid field '%s': %s", err.Field, err.Reason)
|
2018-05-04 06:41:40 +00:00
|
|
|
}
|
|
|
|
|
2021-06-15 22:04:09 +00:00
|
|
|
// ErrIncompleteRequest when mandatory request fields are missing (request-line or headers)
|
|
|
|
// it contains the missing field as a string
|
|
|
|
type ErrIncompleteRequest string
|
2018-05-04 06:41:40 +00:00
|
|
|
|
2021-06-15 22:04:09 +00:00
|
|
|
func (err ErrIncompleteRequest) Error() string {
|
|
|
|
return fmt.Sprintf("incomplete request, '%s' is invalid or missing", string(err))
|
2018-05-04 06:41:40 +00:00
|
|
|
}
|
|
|
|
|
2021-06-15 22:04:09 +00:00
|
|
|
// ErrInvalidOriginPolicy when a request has a violated origin policy
|
|
|
|
type ErrInvalidOriginPolicy struct {
|
2018-05-04 06:41:40 +00:00
|
|
|
Host string
|
|
|
|
Origin string
|
|
|
|
err error
|
|
|
|
}
|
2018-09-29 12:39:12 +00:00
|
|
|
|
2021-06-15 22:04:09 +00:00
|
|
|
func (err ErrInvalidOriginPolicy) Error() string {
|
2018-05-04 06:41:40 +00:00
|
|
|
return fmt.Sprintf("invalid origin policy; (host: '%s' origin: '%s' error: '%s')", err.Host, err.Origin, err.err)
|
2018-09-29 12:39:12 +00:00
|
|
|
}
|