Skip to content

Replace Panicln calls in request handlers with proper error responses #244

@maxwellward

Description

@maxwellward

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions