Skip to content

sjy-dv/Go-CustomErrorHandler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Releases

No releases published

Packages

No packages published

Languages