There are ~101 uses of logger.StdErr.Panicln across the server codebase. Many of these are inside HTTP request handlers (routes/, services/, db/), where a failed DB operation or service call will crash the entire server process.
We should replace these with proper error handling and logging.
We should not replace panics during server initialization like in db/init.go and main.go as we do want the server to exit if something is failing on startup, just not during normal use.
Approach:
- Replace panics in request handlers with
c.JSON(http.StatusInternalServerError, ...) and return
- For panics in
db/ helper functions, return errors to the caller instead of panicking
There are ~101 uses of
logger.StdErr.Paniclnacross the server codebase. Many of these are inside HTTP request handlers (routes/, services/, db/), where a failed DB operation or service call will crash the entire server process.We should replace these with proper error handling and logging.
We should not replace panics during server initialization like in
db/init.goandmain.goas we do want the server to exit if something is failing on startup, just not during normal use.Approach:
c.JSON(http.StatusInternalServerError, ...)and returndb/helper functions, return errors to the caller instead of panicking