Fix coding bugs: Replace panic with proper error handling#2296
Fix coding bugs: Replace panic with proper error handling#2296Mirza-Samad-Ahmed-Baig wants to merge 1 commit intoIceWhaleTech:mainfrom
Conversation
Mirza-Samad-Ahmed-Baig
commented
Jul 14, 2025
- Replace panic() calls with proper error logging in main.go
- Fix potential nil pointer dereference when checking response.StatusCode()
- Replace panic() calls with error returns in httper.go
- Improve error handling for network operations and HTTP responses
- Replace panic() calls with proper error logging in main.go - Fix potential nil pointer dereference when checking response.StatusCode() - Replace panic() calls with error returns in httper.go - Improve error handling for network operations and HTTP responses
|
shedokan
left a comment
There was a problem hiding this comment.
Took the liberty to share some Go knowledge.
Regarding errors - can read about them here - https://preslav.me/2023/04/14/golang-error-handling-is-a-form-of-storytelling/
| } | ||
| if err != nil { | ||
| panic(err) | ||
| return "" |
There was a problem hiding this comment.
How is this "proper error handling"
Error should be bubbled up, so that whomever did the Post can handle it.
Empty content might be ok in some cases
| logger.Error("Failed to create route", zap.Error(err), zap.String("path", apiPath)) | ||
| continue |
There was a problem hiding this comment.
Why continue loading the server? This hides server loading issues, and it takes a while for whomever ran this service to know something is off (as the process didn't exit)
| logger.Error("Server failed to start", zap.Error(err)) | ||
| return |
There was a problem hiding this comment.
return is redundant
| logger.Error("Server failed to start", zap.Error(err)) | |
| return | |
| logger.Error("Server failed to start", zap.Error(err)) |


