diff --git a/client.go b/client.go index 97c5f05..2ed61a5 100644 --- a/client.go +++ b/client.go @@ -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 diff --git a/proto.go b/proto.go index 2ca1d3e..cb29a69 100644 --- a/proto.go +++ b/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()