### Gin Recovery Middleware for Error Handling Source: https://github.com/fabitee/ginutils/blob/main/README.md This snippet demonstrates the use of the `ginutils.Recovery` middleware. It enables writing error-handling functions that return an error and ensures that all errors, including panics, are responded to with a common `ErrorResponse` JSON object. ```go import ( "github.com/gin-gonic/gin" "github.com/fabitee/ginutils" ) // ... inside your Gin server setup ... router := gin.Default() router.Use(ginutils.Recovery()) // Your routes here // Example error handler function func MyHandler(c *gin.Context) error { // Simulate an error return fmt.Errorf("something went wrong") } // The Recovery middleware will catch this error and respond with an ErrorResponse JSON object. ``` -------------------------------- ### ErrorResponse JSON Structure Source: https://github.com/fabitee/ginutils/blob/main/README.md Defines the standard JSON structure for all error responses, ensuring a consistent format for clients. This structure includes the HTTP status code and an error message. ```json { "status": 400, "message": "Missing parameter 'id' in URL" } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.