2022-01-29 18:43:07 +01:00

20 lines
317 B
Go

package api
import (
"net/http"
"github.com/gin-gonic/gin"
)
func (s *Service) Recovery(c *gin.Context) {
defer func() {
if err := recover(); err != nil {
s.Logger.Println("[PANIC]", err)
c.JSON(http.StatusInternalServerError, gin.H{
"error": "an unexpected error occur",
})
}
}()
c.Next()
}