Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
rym-util
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhengqiuyun
rym-util
Commits
94b04f23
Commit
94b04f23
authored
Dec 21, 2022
by
zhengqiuyun86
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
网络通过
parent
3e92c9d9
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
0 deletions
+27
-0
Error.go
getWay/Error.go
+20
-0
Response.go
getWay/Response.go
+7
-0
No files found.
getWay/Error.go
View file @
94b04f23
...
...
@@ -8,6 +8,12 @@ type Error struct {
SubMsg
string
}
type
SError
struct
{
Code
State
SubCode
string
SubMsg
string
}
func
ExceptionGetWayCatch
(
c
*
gin
.
Context
)
{
err
:=
recover
()
//获取异常
if
err
!=
nil
{
...
...
@@ -16,6 +22,10 @@ func ExceptionGetWayCatch(c *gin.Context) {
e
:=
(
err
)
.
(
Error
)
FailGetWay
(
c
,
e
.
Code
,
e
.
SubCode
,
e
.
SubMsg
)
break
case
SError
:
e
:=
(
err
)
.
(
Error
)
SuccessGetWay
(
c
,
e
.
Code
,
e
.
SubCode
,
e
.
SubMsg
)
break
}
}
}
...
...
@@ -24,8 +34,18 @@ func ThrowsGetWayErr(code State, subCode, subMsg string) {
panic
(
Error
{
Code
:
code
,
SubCode
:
subCode
,
SubMsg
:
subMsg
})
}
func
ThrowsGetWaySErr
(
code
State
,
subCode
,
subMsg
string
)
{
panic
(
SError
{
Code
:
code
,
SubCode
:
subCode
,
SubMsg
:
subMsg
})
}
func
AssertThrowsGetWayErr
(
throwable
bool
,
code
State
,
subCode
,
subMsg
string
)
{
if
throwable
{
ThrowsGetWayErr
(
code
,
subCode
,
subMsg
)
}
}
func
AssertThrowsGetWaySErr
(
throwable
bool
,
code
State
,
subCode
,
subMsg
string
)
{
if
throwable
{
ThrowsGetWaySErr
(
code
,
subCode
,
subMsg
)
}
}
getWay/Response.go
View file @
94b04f23
...
...
@@ -41,6 +41,13 @@ func FailGetWay(c *gin.Context, state State, subCode, subMsg string) {
LogEnd
(
c
,
resp
)
}
func
SuccessGetWay
(
c
*
gin
.
Context
,
state
State
,
subCode
,
subMsg
string
)
{
resp
:=
responseSub
(
state
,
subCode
,
subMsg
)
c
.
JSON
(
http
.
StatusOK
,
resp
)
c
.
Abort
()
LogEnd
(
c
,
resp
)
}
func
FailAndMsg
(
c
*
gin
.
Context
,
subCode
,
subMsg
string
)
{
db
.
Rollback
()
resp
:=
ServerResponse
{
Code
:
BusinessError
,
Msg
:
"业务错误"
,
SubCode
:
subCode
,
SubMsg
:
subMsg
}
...
...
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