I'm testing a Go application using Iris. I want to log every error or exception to my Rollbar account.
For instance, if the endpoint takes too long to respond and there is a timeout, I want to log it. How can I capture errors like that?
Update
I found in the documentation the OnError
method, and I thought I could use it like this:
iris.OnError(iris.StatusServiceUnavailable, func(c *iris.Context) {
c.Write("503")
params := string(c.RequestCtx.Request.Body())
rollbar.Error("error", errors.New("503 Service Unavailable"), &rollbar.Field{Name: "request_body", Data: params})
})
But it is not logging the error to Rollbar.