ws/internal/http/upgrade/request/errors.go

35 lines
799 B
Go
Raw Permalink Normal View History

package request
import (
"fmt"
)
// invalid request
// - multiple-value if only 1 expected
type InvalidRequest struct {
Field string
Reason string
}
func (err InvalidRequest) Error() string {
return fmt.Sprintf("Invalid field '%s': %s", err.Field, err.Reason)
}
// Request misses fields (request-line or headers)
type IncompleteRequest struct {
MissingField string
}
func (err IncompleteRequest) Error() string {
return fmt.Sprintf("imcomplete request, '%s' is invalid or missing", err.MissingField)
}
// Request has a violated origin policy
type InvalidOriginPolicy struct {
Host string
Origin string
err error
}
func (err InvalidOriginPolicy) Error() string {
return fmt.Sprintf("invalid origin policy; (host: '%s' origin: '%s' error: '%s')", err.Host, err.Origin, err.err)
}