Catch the panic and print the error #215

Closed
lunny wants to merge 1 commits from lunny:lunny/catch_panic into main
Owner
No description provided.
lunny added 1 commit 2023-05-26 05:44:06 +00:00
Catch the panic and print the error
All checks were successful
checks / check and test (pull_request) Successful in 56s
418dedce30
wxiaoguang reviewed 2023-05-26 05:47:11 +00:00
@ -51,0 +50,4 @@
defer func() {
if r := recover(); r != nil {
// we don't know whether log will panic, so just use fmt
fmt.Printf("panic: %v\n", r)
Member

The logger should never panic ...

I would prefer to always use the logger system.

The logger should never panic ... I would prefer to always use the logger system.
wxiaoguang reviewed 2023-05-26 05:48:38 +00:00
@ -51,0 +52,4 @@
// we don't know whether log will panic, so just use fmt
fmt.Printf("panic: %v\n", r)
}
}()
Member

The for { func() defer func() { seems quite complex, could the code block be moved into a separate function? Then it's easier to do defer - recover.

The `for { func() defer func() {` seems quite complex, could the code block be moved into a separate function? Then it's easier to do defer - recover.
wolfogre added the
kind
enhancement
label 2023-06-05 08:33:05 +00:00
wolfogre closed this pull request 2023-07-24 04:29:06 +00:00
lunny deleted branch lunny/catch_panic 2023-07-24 07:08:13 +00:00
All checks were successful
checks / check and test (pull_request) Successful in 56s
Required
Details

Pull request closed

Sign in to join this conversation.
No description provided.