Skip to content
This repository has been archived by the owner on May 7, 2023. It is now read-only.

Commit

Permalink
Wrap errors to have more helpful messages
Browse files Browse the repository at this point in the history
  • Loading branch information
scoiatael committed Mar 9, 2017
1 parent 07a7cc4 commit 375e087
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions actions/http_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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})
}
Expand All @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 375e087

Please sign in to comment.