-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
@vishr
We have migrated from negroni to echo.
In Negroni, we had a protect-at-last-resort middleware that caught panics.
In Development mode, that middleware would convert the stack trace and return it using this bit of code:
m := map[string]string{}
stack := make([]byte, 1024*8)
stack = stack[:runtime.Stack(stack, false)]
m["stack"] = fmt.Sprintf("%s", stack)
As a matter of practice we always paniced at the Controller level (but not other inside functions called by out controller) when we wanted to produce an error output as a response.
With Echo, we have created a custom error handler. We do the "echo" way which is to return an error instead of panicing.
This error handler does not seem to be able to retrieve a stacktrace from our request handler functions.
Even when we set runtime.Stack(stack, false) to true, it appears that by the time the custom error handler gets called, the request handler's goroutine has ended.
At this stage, we are thinking of reverting back to using a panic instead of returning errors.
Are we doing something wrong? Can you please give us feedback