add initial application structure with configuration, logging, and health check endpoints
This commit is contained in:
@@ -1,14 +1,24 @@
|
||||
package exception
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
|
||||
"epic-ent/internal/domain/vo"
|
||||
)
|
||||
|
||||
func RegisterErrorHandler(e *echo.Echo) {
|
||||
e.HTTPErrorHandler = func(err error, c echo.Context) {
|
||||
_ = c.JSON(500, map[string]any{
|
||||
"code": "INTERNAL_ERROR",
|
||||
"message": err.Error(),
|
||||
})
|
||||
code := http.StatusInternalServerError
|
||||
msg := err.Error()
|
||||
if he, ok := err.(*echo.HTTPError); ok {
|
||||
code = he.Code
|
||||
if he.Message != nil {
|
||||
msg = he.Message.(string)
|
||||
}
|
||||
}
|
||||
|
||||
_ = c.JSON(code, vo.Error(msg))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user