refactor: make no transport error an exported error we can test on

This commit is contained in:
Derrick Hammer 2024-03-05 15:01:22 -05:00
parent 701386c05d
commit 397ed0d6ec
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 5 additions and 1 deletions

View File

@ -6,6 +6,10 @@ import (
"sync"
)
var (
ErrTransportNotSupported = errors.New("no static method registered for type")
)
type TransportPeerConfig struct {
Socket interface{}
Uris []*url.URL
@ -43,7 +47,7 @@ func RegisterTransport(peerType string, factory interface{}) {
func CreateTransportSocket(peerType string, uri *url.URL) (interface{}, error) {
static, ok := transports.Load(peerType)
if !ok {
return nil, errors.New("no static method registered for type: " + peerType)
return nil, ErrTransportNotSupported
}
t, err := static.(PeerStatic).Connect(uri)