sjy-dv / Go-CustomErrorHandler

No more panic and recover

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Panic and recover in Go make development less efficient

1. is use panic case

img1

This is very risky behavior in the development stage.

img2 img3

It is difficult to determine where the error is and it is frustrating at the front side.

To solve this panic, go supports recover.



2. is use recover case

img4 img5

Each recover function is required to expose information about errors.

img6

It is possible to respond to errors, but it requires coercion and complexity of the code.



3. is use custom_errrorhandler case

img8 img9

Basically, it reacts to errors in a handler like recover.

img10

However, starting from the json code, a single error handler can return various errors.

img11

You can handle the return of all errors flexibly with a single handler without having to write each recover individually.

About

No more panic and recover

License:GNU General Public License v3.0


Languages

Language:Go 100.0%