20 lines
317 B
Go
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()
|
|
}
|