veza/veza-backend-api/internal/handlers/error_response.go

22 lines
730 B
Go
Raw Normal View History

2025-12-03 19:29:37 +00:00
package handlers
import (
2026-03-06 18:13:16 +00:00
apperrors "veza-backend-api/internal/errors"
"veza-backend-api/internal/response"
"github.com/gin-gonic/gin"
2025-12-03 19:29:37 +00:00
)
// RespondWithAppError répond avec une AppError au format standardisé ORIGIN_API_SPECIFICATION
2026-03-06 18:13:16 +00:00
// Délègue au package response pour éviter duplication
func RespondWithAppError(c *gin.Context, appErr *apperrors.AppError) {
response.RespondWithAppError(c, appErr)
2025-12-03 19:29:37 +00:00
}
// RespondWithError répond avec un code d'erreur et un message au format standardisé
2026-03-06 18:13:16 +00:00
func RespondWithError(c *gin.Context, code int, message string, details ...apperrors.ErrorDetail) {
appErr := apperrors.New(apperrors.ErrorCode(code), message)
appErr.Details = details
response.RespondWithAppError(c, appErr)
2025-12-03 19:29:37 +00:00
}