go-httpaccept/notacceptable.go

37 lines
765 B
Go
Raw Permalink Normal View History

2023-08-11 19:09:18 +00:00
package httpaccept
import (
"fmt"
"strings"
)
var _ error = &internalNotAcceptable{}
type internalNotAcceptable struct {
mediatypes []string
}
func (receiver internalNotAcceptable) Error() string {
var mediatypes []string = receiver.mediatypes
if len(mediatypes) < 1 {
return "httpaccept: none of the provided media-types are acceptable, because an empty list of media-types was provided"
}
var buffer strings.Builder
buffer.WriteString("httpaccept: none of the provided media-types are acceptable —")
for _, mediatype := range mediatypes {
fmt.Fprintf(&buffer, " %q", mediatype)
}
return buffer.String()
}
func (internalNotAcceptable) ClientError() {
// Nothing here.
}
func (internalNotAcceptable) NotAcceptable() {
// Nothing here.
}