package websocket

import (
	"fmt"
	"strings"

	"github.com/gobwas/ws"
	"github.com/pkg/errors"
)

func isNormalClosure(err error) bool {
	return strings.Contains(err.Error(), fmt.Sprintf("%d", ws.StatusNormalClosure))
}

var ErrFailedAuthentication = errors.New("failed authentication")
var ErrFailedToLoad = errors.New("failed loading")

var ErrInvalidHeaders = errors.New("request missing header Ssl-Client-Subject-Dn")
var ErrInvalidToken = errors.New("token missing username field")

func ErrInvalidHandler(handler string) error {
	return errors.Errorf("%s is an invalid message handler", handler)
}
