Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
孙龙
/
golang-callback
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
55310da5
authored
Jun 21, 2021
by
孙龙
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
up
parent
b0140f98
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
7 deletions
middleware/recovery.go
middleware/recovery.go
View file @
55310da5
...
@@ -4,10 +4,8 @@ import (
...
@@ -4,10 +4,8 @@ import (
"errors"
"errors"
"fmt"
"fmt"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin"
common
"golang-callback/app/common/function"
"golang-callback/util"
"github.com/ichunt2019/cfg/lib"
"github.com/ichunt2019/cfg/lib"
"runtime/debug
"
common
"golang-callback/app/common/function
"
)
)
// RecoveryMiddleware捕获所有panic,并且返回错误信息
// RecoveryMiddleware捕获所有panic,并且返回错误信息
...
@@ -18,10 +16,10 @@ func RecoveryMiddleware() gin.HandlerFunc {
...
@@ -18,10 +16,10 @@ func RecoveryMiddleware() gin.HandlerFunc {
if
err
:=
recover
();
err
!=
nil
{
if
err
:=
recover
();
err
!=
nil
{
//先做一下日志记录
//先做一下日志记录
//fmt.Println(string(debug.Stack()))
//fmt.Println(string(debug.Stack()))
util
.
ComLogNotice
(
c
,
"_com_panic"
,
map
[
string
]
interface
{}{
//
util.ComLogNotice(c, "_com_panic", map[string]interface{}{
"error"
:
fmt
.
Sprint
(
err
),
//
"error": fmt.Sprint(err),
"stack"
:
string
(
debug
.
Stack
()),
//
"stack": string(debug.Stack()),
})
//
})
if
lib
.
Instance
(
"proxy"
)
.
GetString
(
"base.debug_mode"
)
!=
"debug"
{
if
lib
.
Instance
(
"proxy"
)
.
GetString
(
"base.debug_mode"
)
!=
"debug"
{
//ResponseError(c, 500, errors.New("内部错误"))
//ResponseError(c, 500, errors.New("内部错误"))
common
.
Output
(
c
,
500
,
"内部错误"
,
nil
)
common
.
Output
(
c
,
500
,
"内部错误"
,
nil
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment