diff --git a/backend-go/internal/application/services/helpers.go b/backend-go/internal/application/services/helpers.go index efeb493..4967bce 100644 --- a/backend-go/internal/application/services/helpers.go +++ b/backend-go/internal/application/services/helpers.go @@ -12,12 +12,18 @@ func HandleError(c *gin.Context) func(error) any { return func(err error) any { // Check if the error is of type *AppError if appErr, ok := err.(*app_error.AppError); ok { - // Use the AppError fields for the JSON response - c.JSON(appErr.Status, gin.H{ + response := gin.H{ "code": appErr.Code, "message": appErr.Message, - "details": appErr.Err.Error(), // Original error if available - }) + } + + // Add details if available + if appErr.Err != nil { + response["details"] = appErr.Err.Error() + } + + // Use the AppError fields for the JSON response + c.JSON(appErr.Status, response) } else { // Fallback for non-AppError errors c.JSON(http.StatusInternalServerError, gin.H{