From 375e0872ded6933bb949c9ddbbfbf3fca1716d14 Mon Sep 17 00:00:00 2001 From: scoiatael Date: Thu, 9 Mar 2017 11:46:34 +0100 Subject: [PATCH] Wrap errors to have more helpful messages --- actions/http_server.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/actions/http_server.go b/actions/http_server.go index 3fb761c..b3408a1 100644 --- a/actions/http_server.go +++ b/actions/http_server.go @@ -27,6 +27,7 @@ func writer(jobs <-chan WriteJob, c Context) { func (wj *WriteJob) Run(c Context) { payload, err := json.Marshal(wj.payload) + err = errors.Wrap(err, "HTTP server marshalling payload to write event") if err != nil { c.HandleErr(err) return @@ -36,7 +37,7 @@ func (wj *WriteJob) Run(c Context) { action.Meta["compressed"] = "false" err = action.Run(c) if err != nil { - c.HandleErr(err) + c.HandleErr(errors.Wrap(err, "HTTP server writing event")) } else { c.Telemetry().Incr("write", []string{"stream:" + wj.stream}) } @@ -56,7 +57,7 @@ func (hs HttpServer) Run(c Context) error { action := ReadEvents{Stream: stream} action.Cursor = ctx.StringParam("cursor") action.Amount = ctx.IntParam("amount", 10) - err := action.Run(c) + err := errors.Wrap(action.Run(c), "HTTP server reading events") if err != nil { c.HandleErr(err) ctx.ServerErr(err) @@ -67,6 +68,7 @@ func (hs HttpServer) Run(c Context) error { events[i] = make(simplejson.Object) events[i]["ID"] = ev.ID payload, err := simplejson.Read(ev.Blob) + err = errors.Wrap(err, "HTTP server marshalling response with read events") if err != nil { c.HandleErr(err) ctx.ServerErr(err)