mirror of
https://github.com/simon987/task_tracker.git
synced 2025-04-19 10:16:41 +00:00
26 lines
392 B
Go
26 lines
392 B
Go
package api
|
|
|
|
import (
|
|
"github.com/Sirupsen/logrus"
|
|
"runtime/debug"
|
|
)
|
|
|
|
type ErrorResponse struct {
|
|
Message string `json:"message"`
|
|
StackTrace string `json:"stack_trace"`
|
|
|
|
}
|
|
|
|
func handleErr(err error, r *Request) {
|
|
|
|
if err != nil {
|
|
logrus.Error(err.Error())
|
|
//debug.PrintStack()
|
|
|
|
r.Json(ErrorResponse{
|
|
Message: err.Error(),
|
|
StackTrace: string(debug.Stack()),
|
|
}, 500)
|
|
}
|
|
}
|