diff --git a/_examples/bridge/main.go b/_examples/bridge/main.go index 9e9ce8c..e42fd98 100644 --- a/_examples/bridge/main.go +++ b/_examples/bridge/main.go @@ -5,12 +5,12 @@ import ( "sync" "github.com/inconshreveable/log15" + "github.com/rotisserie/eris" "github.com/CyCoreSystems/ari-proxy/v5/client" "github.com/CyCoreSystems/ari/v5" "github.com/CyCoreSystems/ari/v5/ext/play" "github.com/CyCoreSystems/ari/v5/rid" - "github.com/pkg/errors" ) var ariApp = "test" @@ -82,7 +82,7 @@ func ensureBridge(ctx context.Context, cl ari.Client, src *ari.Key) (err error) bridge, err = cl.Bridge().Create(key, "mixing", key.ID) if err != nil { bridge = nil - return errors.Wrap(err, "failed to create bridge") + return eris.Wrap(err, "failed to create bridge") } wg := new(sync.WaitGroup) diff --git a/client/client.go b/client/client.go index 35e399d..b7e6a5a 100644 --- a/client/client.go +++ b/client/client.go @@ -11,10 +11,10 @@ import ( "github.com/CyCoreSystems/ari-proxy/v5/proxy" "github.com/CyCoreSystems/ari/v5" "github.com/CyCoreSystems/ari/v5/rid" + "github.com/rotisserie/eris" "github.com/inconshreveable/log15" "github.com/nats-io/nats.go" - "github.com/pkg/errors" ) // ClosureGracePeriod is the amount of time to wait after the closure of the @@ -39,7 +39,7 @@ const DefaultInputBufferLength = 100 var DefaultClusterMaxAge = 5 * time.Minute // ErrNil indicates that the request returned an empty response -var ErrNil = errors.New("Nil") +var ErrNil = eris.New("Nil") // core is the core, functional piece of a Client which is the same across the // family of derived clients. It manages stateful elements such as the bus, @@ -146,14 +146,14 @@ func (c *core) Start() error { n, err := nats.Connect(c.uri) if err != nil { c.close() - return errors.Wrap(err, "failed to connect to NATS") + return eris.Wrap(err, "failed to connect to NATS") } c.nc, err = nats.NewEncodedConn(n, nats.JSON_ENCODER) if err != nil { n.Close() // need this here because nc is not yet bound to the core c.close() - return errors.Wrap(err, "failed to encode NATS connection") + return eris.Wrap(err, "failed to encode NATS connection") } c.closeNATSOnClose = true @@ -166,7 +166,7 @@ func (c *core) Start() error { err := c.maintainCluster() if err != nil { c.close() - return errors.Wrap(err, "failed to start cluster maintenance") + return eris.Wrap(err, "failed to start cluster maintenance") } return nil @@ -177,7 +177,7 @@ func (c *core) maintainCluster() (err error) { c.cluster.Update(o.Node, o.Application) }) if err != nil { - return errors.Wrap(err, "failed to listen to proxy announcements") + return eris.Wrap(err, "failed to listen to proxy announcements") } // Send an initial ping for proxy announcements @@ -230,7 +230,7 @@ func New(ctx context.Context, opts ...OptionFunc) (*Client, error) { // Start the core, if it is not already started err := c.core.Start() if err != nil { - return nil, errors.Wrap(err, "failed to start core") + return nil, eris.Wrap(err, "failed to start core") } // Create the bus @@ -529,7 +529,7 @@ func (c *Client) makeRequest(class string, req *proxy.Request) (*proxy.Response, func (c *Client) makeRequests(class string, req *proxy.Request) (responses []*proxy.Response, err error) { if req == nil { - return nil, errors.New("empty request") + return nil, eris.New("empty request") } if req.Key == nil { req.Key = ari.NewKey("", "") @@ -549,14 +549,14 @@ func (c *Client) makeRequests(class string, req *proxy.Request) (responses []*pr } }) if err != nil { - return nil, errors.Wrap(err, "failed to subscribe to data responses") + return nil, eris.Wrap(err, "failed to subscribe to data responses") } defer replySub.Unsubscribe() // nolint: errcheck // Make an all-call for the entity data err = c.core.nc.PublishRequest(c.subject(class, req), reply, req) if err != nil { - return nil, errors.Wrap(err, "failed to make request for data") + return nil, eris.Wrap(err, "failed to make request for data") } // Wait for replies @@ -607,7 +607,7 @@ func (f *limitedResponseForwarder) Forward(o *proxy.Response) { // TODO: simplify func (c *Client) makeBroadcastRequestReturnFirstGoodResponse(class string, req *proxy.Request) (*proxy.Response, error) { if req == nil { - return nil, errors.New("empty request") + return nil, eris.New("empty request") } if req.Key == nil { @@ -623,13 +623,13 @@ func (c *Client) makeBroadcastRequestReturnFirstGoodResponse(class string, req * replySub, err := c.core.nc.Subscribe(reply, rf.Forward) if err != nil { - return nil, errors.Wrap(err, "failed to subscribe to data responses") + return nil, eris.Wrap(err, "failed to subscribe to data responses") } defer replySub.Unsubscribe() // nolint: errcheck // Make an all-call for the entity data if err = c.core.nc.PublishRequest(c.subject(class, req), reply, req); err != nil { - return nil, errors.Wrap(err, "failed to make request for data") + return nil, eris.Wrap(err, "failed to make request for data") } // Wait for replies @@ -638,14 +638,14 @@ func (c *Client) makeBroadcastRequestReturnFirstGoodResponse(class string, req * case <-time.After(c.requestTimeout): // Return the last error if we got one; otherwise, return a timeout error if err == nil { - err = errors.New("timeout") + err = eris.New("timeout") } return nil, err case resp, more := <-rf.fwdChan: if !more { if err == nil { - err = errors.New("no data") + err = eris.New("no data") } return nil, err diff --git a/client/listen.go b/client/listen.go index 5e114ae..8d53870 100644 --- a/client/listen.go +++ b/client/listen.go @@ -6,7 +6,7 @@ import ( "github.com/CyCoreSystems/ari/v5" "github.com/nats-io/nats.go" - "github.com/pkg/errors" + "github.com/rotisserie/eris" ) // ListenQueue is the queue group to use for distributing StasisStart events to Listeners. @@ -22,7 +22,7 @@ var ListenQueue = "ARIProxyStasisStartDistributorQueue" func Listen(ctx context.Context, ac ari.Client, h func(*ari.ChannelHandle, *ari.StasisStart)) error { c, ok := ac.(*Client) if !ok { - return errors.New("ARI Client must be a proxy client") + return eris.New("ARI Client must be a proxy client") } subj := fmt.Sprintf("%sevent.%s.>", c.core.prefix, c.ApplicationName()) @@ -30,7 +30,7 @@ func Listen(ctx context.Context, ac ari.Client, h func(*ari.ChannelHandle, *ari. c.log.Debug("listening for events", "subject", subj) sub, err := c.nc.QueueSubscribe(subj, ListenQueue, listenProcessor(ac, h)) if err != nil { - return errors.Wrap(err, "failed to subscribe to events") + return eris.Wrap(err, "failed to subscribe to events") } defer sub.Unsubscribe() // nolint: errcheck diff --git a/go.mod b/go.mod index 4f5a9ee..e8b823f 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.14 require ( github.com/BurntSushi/toml v0.3.1 // indirect - github.com/CyCoreSystems/ari/v5 v5.0.8 + github.com/CyCoreSystems/ari/v5 v5.1.2 github.com/fsnotify/fsnotify v0.0.0-20170329110642-4da3e2cfbabc // indirect github.com/gogo/protobuf v1.3.1 // indirect github.com/hashicorp/hcl v0.0.0-20170509225359-392dba7d905e // indirect @@ -16,7 +16,7 @@ require ( github.com/nats-io/nats-server/v2 v2.0.0 // indirect github.com/nats-io/nats.go v1.8.1 github.com/pelletier/go-toml v0.0.0-20170817000623-4692b8f9babf // indirect - github.com/pkg/errors v0.8.1 + github.com/rotisserie/eris v0.4.1 github.com/spf13/afero v0.0.0-20170217164146-9be650865eab // indirect github.com/spf13/cast v1.1.0 // indirect github.com/spf13/cobra v0.0.2 diff --git a/go.sum b/go.sum index 13a95a3..9add8e3 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,9 @@ github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/CyCoreSystems/ari/v5 v5.0.8 h1:tyH0P1cSTR4T7fKzuq+3mUb7We9ksosIOp5yhO1HQ5A= -github.com/CyCoreSystems/ari/v5 v5.0.8/go.mod h1:X/wSaIuDdleDdI9gK3s6EuPFuBDFKYoUUzOPqVeOqPA= +github.com/CyCoreSystems/ari/v5 v5.1.1 h1:BGPqCIQzgKDpF89L9RWixbXDnr9QZbc93Z2gDusajNk= +github.com/CyCoreSystems/ari/v5 v5.1.1/go.mod h1:oSoeAuafmlIRrsIlQEQXpyo2k2sCBBVBVtaNXyTixSw= +github.com/CyCoreSystems/ari/v5 v5.1.2 h1:/Ze75yyANGLo1VhhJZ69dXfdeVhc9pvi+AnQWTPkTws= +github.com/CyCoreSystems/ari/v5 v5.1.2/go.mod h1:oSoeAuafmlIRrsIlQEQXpyo2k2sCBBVBVtaNXyTixSw= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -53,10 +55,10 @@ github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/pelletier/go-toml v0.0.0-20170817000623-4692b8f9babf h1:XjB5kVAWxe9qH3eZIUfsW4gLh7prYlRJmZ5zRjyvCeg= github.com/pelletier/go-toml v0.0.0-20170817000623-4692b8f9babf/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= -github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rotisserie/eris v0.4.1 h1:0IHaklBg2X5z10qpXS8F6eR3bUM2Xsbr1bH8W/eLUlo= +github.com/rotisserie/eris v0.4.1/go.mod h1:lODN/gtqebxPHRbCcWeCYOE350FC2M3V/oAPT2wKxAU= github.com/spf13/afero v0.0.0-20170217164146-9be650865eab h1:IVAbBHQR8rXL2Fc8Zba/lMF7KOnTi70lqdx91UTuAwQ= github.com/spf13/afero v0.0.0-20170217164146-9be650865eab/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/cast v1.1.0 h1:0Rhw4d6C8J9VPu6cjZLIhZ8+aAOHcDvGeKn+cq5Aq3k= diff --git a/internal/integration/application.go b/internal/integration/application.go index 00b88b3..1a3d1b4 100644 --- a/internal/integration/application.go +++ b/internal/integration/application.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/CyCoreSystems/ari/v5" - "github.com/pkg/errors" + "github.com/rotisserie/eris" tmock "github.com/stretchr/testify/mock" ) @@ -60,12 +60,12 @@ func TestApplicationData(t *testing.T, s Server) { }) runTest("error", t, s, func(t *testing.T, m *mock, cl ari.Client) { - expected := errors.New("unknown error") + expected := eris.New("unknown error") m.Application.On("Data", key).Return(nil, expected) res, err := cl.Application().Data(key) - if err == nil || errors.Cause(err).Error() != expected.Error() { + if err == nil || eris.Cause(err).Error() != expected.Error() { t.Errorf("Expected error '%v', got '%v'", expected, err) } if res != nil { @@ -94,11 +94,11 @@ func TestApplicationSubscribe(t *testing.T, s Server) { }) runTest("error", t, s, func(t *testing.T, m *mock, cl ari.Client) { - expected := errors.New("unknown error") + expected := eris.New("unknown error") m.Application.On("Subscribe", key, "2").Return(expected) - if err := cl.Application().Subscribe(key, "2"); err == nil || errors.Cause(err).Error() != expected.Error() { + if err := cl.Application().Subscribe(key, "2"); err == nil || eris.Cause(err).Error() != expected.Error() { t.Errorf("Expected error '%v', got '%v'", expected, err) } @@ -124,11 +124,11 @@ func TestApplicationUnsubscribe(t *testing.T, s Server) { }) runTest("error", t, s, func(t *testing.T, m *mock, cl ari.Client) { - expected := errors.New("unknown error") + expected := eris.New("unknown error") m.Application.On("Unsubscribe", key, "2").Return(expected) - if err := cl.Application().Unsubscribe(key, "2"); err == nil || errors.Cause(err).Error() != expected.Error() { + if err := cl.Application().Unsubscribe(key, "2"); err == nil || eris.Cause(err).Error() != expected.Error() { t.Errorf("Expected error '%v', got '%v'", expected, err) } diff --git a/internal/integration/asterisk.go b/internal/integration/asterisk.go index 07dc0d6..b7b3112 100644 --- a/internal/integration/asterisk.go +++ b/internal/integration/asterisk.go @@ -5,7 +5,7 @@ import ( "github.com/CyCoreSystems/ari/v5" "github.com/CyCoreSystems/ari/v5/client/arimocks" - "github.com/pkg/errors" + "github.com/rotisserie/eris" ) func TestAsteriskInfo(t *testing.T, s Server) { @@ -29,12 +29,12 @@ func TestAsteriskInfo(t *testing.T, s Server) { }) runTest("noFilterError", t, s, func(t *testing.T, m *mock, cl ari.Client) { - expected := errors.New("unknown error") + expected := eris.New("unknown error") m.Asterisk.On("Info", ari.NodeKey("asdf", "1")).Return(nil, expected) ret, err := cl.Asterisk().Info(ari.NodeKey("asdf", "1")) - if err == nil || errors.Cause(err).Error() != expected.Error() { + if err == nil || eris.Cause(err).Error() != expected.Error() { t.Errorf("Expected error '%v', got '%v'", expected, err) } if ret != nil { @@ -73,7 +73,7 @@ func TestAsteriskVariablesGet(t *testing.T, s Server) { }) runTest("error", t, s, func(t *testing.T, m *mock, cl ari.Client) { - expected := errors.New("unknown error") + expected := eris.New("unknown error") mv := arimocks.AsteriskVariables{} mv.On("Get", key).Return("", expected) @@ -81,7 +81,7 @@ func TestAsteriskVariablesGet(t *testing.T, s Server) { m.Asterisk.On("Variables").Return(&mv) ret, err := cl.Asterisk().Variables().Get(key) - if err == nil || errors.Cause(err).Error() != expected.Error() { + if err == nil || eris.Cause(err).Error() != expected.Error() { t.Errorf("Expected error '%v', got '%v'", expected, err) } if ret != "" { @@ -123,7 +123,7 @@ func TestAsteriskVariablesSet(t *testing.T, s Server) { mv := arimocks.AsteriskVariables{} m.Asterisk.On("Variables").Return(&mv) - mv.On("Set", key, "hello").Return(errors.New("error")) + mv.On("Set", key, "hello").Return(eris.New("error")) err := cl.Asterisk().Variables().Set(key, "hello") if err == nil { diff --git a/internal/integration/bridge.go b/internal/integration/bridge.go index b31f8af..7bb6e97 100644 --- a/internal/integration/bridge.go +++ b/internal/integration/bridge.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/CyCoreSystems/ari/v5" - "github.com/pkg/errors" + "github.com/rotisserie/eris" ) func TestBridgeCreate(t *testing.T, s Server) { @@ -32,12 +32,12 @@ func TestBridgeCreate(t *testing.T, s Server) { }) runTest("error", t, s, func(t *testing.T, m *mock, cl ari.Client) { - expected := errors.New("unknown error") + expected := eris.New("unknown error") m.Bridge.On("Create", key, "bridgeType", "bridgeName").Return(nil, expected) ret, err := cl.Bridge().Create(key, "bridgeType", "bridgeName") - if err == nil || errors.Cause(err).Error() != expected.Error() { + if err == nil || eris.Cause(err).Error() != expected.Error() { t.Errorf("Expected error '%v', got '%v'", expected, err) } if ret != nil { @@ -75,12 +75,12 @@ func TestBridgeList(t *testing.T, s Server) { }) runTest("error", t, s, func(t *testing.T, m *mock, cl ari.Client) { - expected := errors.New("unknown error") + expected := eris.New("unknown error") m.Bridge.On("List", (*ari.Key)(nil)).Return([]*ari.Key{}, expected) ret, err := cl.Bridge().List(nil) - if err == nil || errors.Cause(err).Error() != expected.Error() { + if err == nil || eris.Cause(err).Error() != expected.Error() { t.Errorf("Expected error '%v', got '%v'", expected, err) } if len(ret) != 0 { @@ -118,7 +118,7 @@ func TestBridgeData(t *testing.T, s Server) { }) runTest("error", t, s, func(t *testing.T, m *mock, cl ari.Client) { - m.Bridge.On("Data", key).Return(nil, errors.New("Error getting data")) + m.Bridge.On("Data", key).Return(nil, eris.New("Error getting data")) ret, err := cl.Bridge().Data(key) if err == nil { @@ -151,7 +151,7 @@ func TestBridgeAddChannel(t *testing.T, s Server) { }) runTest("error", t, s, func(t *testing.T, m *mock, cl ari.Client) { - m.Bridge.On("AddChannel", key, "channel1").Return(errors.New("unknown error")) + m.Bridge.On("AddChannel", key, "channel1").Return(eris.New("unknown error")) err := cl.Bridge().AddChannel(key, "channel1") if err == nil { @@ -181,7 +181,7 @@ func TestBridgeRemoveChannel(t *testing.T, s Server) { }) runTest("error", t, s, func(t *testing.T, m *mock, cl ari.Client) { - m.Bridge.On("RemoveChannel", key, "channel1").Return(errors.New("unknown error")) + m.Bridge.On("RemoveChannel", key, "channel1").Return(eris.New("unknown error")) err := cl.Bridge().RemoveChannel(key, "channel1") if err == nil { @@ -211,7 +211,7 @@ func TestBridgeDelete(t *testing.T, s Server) { }) runTest("error", t, s, func(t *testing.T, m *mock, cl ari.Client) { - m.Bridge.On("Delete", key).Return(errors.New("unknown error")) + m.Bridge.On("Delete", key).Return(eris.New("unknown error")) err := cl.Bridge().Delete(key) if err == nil { @@ -246,7 +246,7 @@ func TestBridgePlay(t *testing.T, s Server) { }) runTest("error", t, s, func(t *testing.T, m *mock, cl ari.Client) { - m.Bridge.On("Play", key, "playback1", "mediaURI").Return(nil, errors.New("unknown error")) + m.Bridge.On("Play", key, "playback1", "mediaURI").Return(nil, eris.New("unknown error")) ret, err := cl.Bridge().Play(key, "playback1", "mediaURI") if err == nil { @@ -326,7 +326,7 @@ func TestBridgeRecord(t *testing.T, s Server) { m.Bridge.On("Data", key).Return(bd, nil) opts := &ari.RecordingOptions{} - m.Bridge.On("Record", key, "recording1", opts).Return(nil, errors.New("unknown error")) + m.Bridge.On("Record", key, "recording1", opts).Return(nil, eris.New("unknown error")) ret, err := cl.Bridge().Record(key, "recording1", opts) if err == nil { diff --git a/internal/integration/clientserver.go b/internal/integration/clientserver.go index b50599b..1db658f 100644 --- a/internal/integration/clientserver.go +++ b/internal/integration/clientserver.go @@ -10,17 +10,17 @@ import ( "github.com/CyCoreSystems/ari/v5" "github.com/nats-io/nats.go" - "github.com/pkg/errors" + "github.com/rotisserie/eris" ) func natsConnect() (*nats.EncodedConn, error) { c, err := nats.Connect(nats.DefaultURL) if err != nil { - return nil, errors.Wrap(err, "failed to connect to NATS") + return nil, eris.Wrap(err, "failed to connect to NATS") } nc, err := nats.NewEncodedConn(c, nats.JSON_ENCODER) if err != nil { - return nil, errors.Wrap(err, "failed to encode NATS connection") + return nil, eris.Wrap(err, "failed to encode NATS connection") } return nc, err } diff --git a/server/server.go b/server/server.go index 389a246..902b5d3 100644 --- a/server/server.go +++ b/server/server.go @@ -3,17 +3,17 @@ package server import ( "context" "fmt" - "time" "os" + "time" "github.com/CyCoreSystems/ari-proxy/v5/proxy" "github.com/CyCoreSystems/ari-proxy/v5/server/dialog" "github.com/CyCoreSystems/ari/v5" "github.com/CyCoreSystems/ari/v5/client/native" + "github.com/rotisserie/eris" "github.com/inconshreveable/log15" "github.com/nats-io/nats.go" - "github.com/pkg/errors" ) // DefaultReconnectionAttemts is the default number of reconnection attempts @@ -75,7 +75,7 @@ func (s *Server) Listen(ctx context.Context, ariOpts *native.Options, natsURI st // Connect to ARI s.ari, err = native.Connect(ariOpts) if err != nil { - return errors.Wrap(err, "failed to connect to ARI") + return eris.Wrap(err, "failed to connect to ARI") } defer s.ari.Close() @@ -89,11 +89,11 @@ func (s *Server) Listen(ctx context.Context, ariOpts *native.Options, natsURI st reconnectionAttempts -= 1 } if err != nil { - return errors.Wrap(err, "failed to connect to NATS") + return eris.Wrap(err, "failed to connect to NATS") } s.nats, err = nats.NewEncodedConn(nc, nats.JSON_ENCODER) if err != nil { - return errors.Wrap(err, "failed to encode NATS connection") + return eris.Wrap(err, "failed to encode NATS connection") } defer s.nats.Close() @@ -136,12 +136,12 @@ func (s *Server) listen(ctx context.Context) error { ret, err := s.ari.Asterisk().Info(nil) if err != nil { - return errors.Wrap(err, "failed to get Asterisk ID") + return eris.Wrap(err, "failed to get Asterisk ID") } s.AsteriskID = ret.SystemInfo.EntityID if s.AsteriskID == "" { - return errors.New("empty Asterisk ID") + return eris.New("empty Asterisk ID") } // Store the ARI application name for top-level access @@ -154,7 +154,7 @@ func (s *Server) listen(ctx context.Context) error { // ping handler pingSub, err := s.nats.Subscribe(proxy.PingSubject(s.NATSPrefix), s.pingHandler) if err != nil { - return errors.Wrap(err, "failed to subscribe to pings") + return eris.Wrap(err, "failed to subscribe to pings") } defer wg.Add(pingSub.Unsubscribe) @@ -164,69 +164,69 @@ func (s *Server) listen(ctx context.Context) error { // get handlers allGet, err := s.nats.Subscribe(proxy.Subject(s.NATSPrefix, "get", "", ""), requestHandler) if err != nil { - return errors.Wrap(err, "failed to create get-all subscription") + return eris.Wrap(err, "failed to create get-all subscription") } defer wg.Add(allGet.Unsubscribe)() appGet, err := s.nats.Subscribe(proxy.Subject(s.NATSPrefix, "get", s.Application, ""), requestHandler) if err != nil { - return errors.Wrap(err, "failed to create get-app subscription") + return eris.Wrap(err, "failed to create get-app subscription") } defer wg.Add(appGet.Unsubscribe)() idGet, err := s.nats.Subscribe(proxy.Subject(s.NATSPrefix, "get", s.Application, s.AsteriskID), requestHandler) if err != nil { - return errors.Wrap(err, "failed to create get-id subscription") + return eris.Wrap(err, "failed to create get-id subscription") } defer wg.Add(idGet.Unsubscribe)() // data handlers allData, err := s.nats.Subscribe(proxy.Subject(s.NATSPrefix, "data", "", ""), requestHandler) if err != nil { - return errors.Wrap(err, "failed to create data-all subscription") + return eris.Wrap(err, "failed to create data-all subscription") } defer wg.Add(allData.Unsubscribe)() appData, err := s.nats.Subscribe(proxy.Subject(s.NATSPrefix, "data", s.Application, ""), requestHandler) if err != nil { - return errors.Wrap(err, "failed to create data-app subscription") + return eris.Wrap(err, "failed to create data-app subscription") } defer wg.Add(appData.Unsubscribe)() idData, err := s.nats.Subscribe(proxy.Subject(s.NATSPrefix, "data", s.Application, s.AsteriskID), requestHandler) if err != nil { - return errors.Wrap(err, "failed to create data-id subscription") + return eris.Wrap(err, "failed to create data-id subscription") } defer wg.Add(idData.Unsubscribe)() // command handlers allCommand, err := s.nats.Subscribe(proxy.Subject(s.NATSPrefix, "command", "", ""), requestHandler) if err != nil { - return errors.Wrap(err, "failed to create command-all subscription") + return eris.Wrap(err, "failed to create command-all subscription") } defer wg.Add(allCommand.Unsubscribe)() appCommand, err := s.nats.Subscribe(proxy.Subject(s.NATSPrefix, "command", s.Application, ""), requestHandler) if err != nil { - return errors.Wrap(err, "failed to create command-app subscription") + return eris.Wrap(err, "failed to create command-app subscription") } defer wg.Add(appCommand.Unsubscribe)() idCommand, err := s.nats.Subscribe(proxy.Subject(s.NATSPrefix, "command", s.Application, s.AsteriskID), requestHandler) if err != nil { - return errors.Wrap(err, "failed to create command-id subscription") + return eris.Wrap(err, "failed to create command-id subscription") } defer wg.Add(idCommand.Unsubscribe)() // create handlers allCreate, err := s.nats.QueueSubscribe(proxy.Subject(s.NATSPrefix, "create", "", ""), "ariproxy", requestHandler) if err != nil { - return errors.Wrap(err, "failed to create create-all subscription") + return eris.Wrap(err, "failed to create create-all subscription") } defer wg.Add(allCreate.Unsubscribe)() appCreate, err := s.nats.QueueSubscribe(proxy.Subject(s.NATSPrefix, "create", s.Application, ""), "ariproxy", requestHandler) if err != nil { - return errors.Wrap(err, "failed to create create-app subscription") + return eris.Wrap(err, "failed to create create-app subscription") } defer wg.Add(appCreate.Unsubscribe)() idCreate, err := s.nats.QueueSubscribe(proxy.Subject(s.NATSPrefix, "create", s.Application, s.AsteriskID), "ariproxy", requestHandler) if err != nil { - return errors.Wrap(err, "failed to create create-id subscription") + return eris.Wrap(err, "failed to create create-id subscription") } defer wg.Add(idCreate.Unsubscribe)() @@ -343,7 +343,7 @@ func (s *Server) publish(subject string, msg interface{}) { func (s *Server) newRequestHandler(ctx context.Context) func(subject string, reply string, req *proxy.Request) { return func(subject string, reply string, req *proxy.Request) { if !s.ari.Connected() { - s.sendError(reply, errors.New("ARI connection is down")) + s.sendError(reply, eris.New("ARI connection is down")) return } go s.dispatchRequest(ctx, reply, req) @@ -579,7 +579,7 @@ func (s *Server) dispatchRequest(ctx context.Context, reply string, req *proxy.R f = s.soundList default: f = func(ctx context.Context, reply string, req *proxy.Request) { - s.sendError(reply, errors.New("Not implemented")) + s.sendError(reply, eris.New("Not implemented")) } }