From 7c2b347ef4dc549404161775ec389c8cbd87c4ad Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Wed, 6 Mar 2019 16:26:51 +0300 Subject: [PATCH] gobreaker: fix error parsing Signed-off-by: Vasiliy Tolstov --- gobreaker.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/gobreaker.go b/gobreaker.go index 50b7c88..9b6327d 100644 --- a/gobreaker.go +++ b/gobreaker.go @@ -52,20 +52,21 @@ func (c *clientWrapper) Call(ctx context.Context, req client.Request, rsp interf return nil } - switch err.(type) { - case *errors.Error: - break - default: - err = errors.New(req.Service(), err.Error(), 503) + merr := errors.Parse(err.Error()) + switch { + case merr.Code == 0: + merr.Code = 503 + case len(merr.Id) == 0: + merr.Id = req.Service() } - if err.(*errors.Error).Code >= 500 { + if merr.Code >= 500 { cbAllow(false) } else { cbAllow(true) } - return err + return merr } // NewClientWrapper returns a client Wrapper.