mirror of
https://github.com/logos-messaging/go-waku-rendezvous.git
synced 2026-01-02 13:13:08 +00:00
use discriminated registration errors
This commit is contained in:
parent
1506c04f1a
commit
7e5664ce7c
@ -66,7 +66,7 @@ func (cli *client) Register(ctx context.Context, ns string, ttl int) error {
|
||||
|
||||
status := res.GetRegisterResponse().GetStatus()
|
||||
if status != pb.Message_OK {
|
||||
return fmt.Errorf("Registration failure: %s", status.String())
|
||||
return RegistrationError(status)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
6
proto.go
6
proto.go
@ -13,6 +13,12 @@ const (
|
||||
RendezvousProto = protocol.ID("/rendezvous/1.0.0")
|
||||
)
|
||||
|
||||
type RegistrationError pb.Message_RegisterStatus
|
||||
|
||||
func (e RegistrationError) Error() string {
|
||||
return pb.Message_RegisterStatus(e).String()
|
||||
}
|
||||
|
||||
func newRegisterMessage(ns string, pi pstore.PeerInfo, ttl int) *pb.Message {
|
||||
msg := new(pb.Message)
|
||||
msg.Type = pb.Message_REGISTER.Enum()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user