mirror of
https://github.com/simon987/task_tracker.git
synced 2025-12-13 23:09:02 +00:00
Initial commit
This commit is contained in:
25
api/error.go
Normal file
25
api/error.go
Normal file
@@ -0,0 +1,25 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user