I'll explain when you're older!
Some checks failed
🧪 ✨ Unit Tests Workflow / 🧪 📜 JavaScript Tests (push) Successful in 1m38s
🧪 ✨ Unit Tests Workflow / 🧪 🐹 GolangCI-Lint (push) Failing after 2m36s
🧪 ✨ Unit Tests Workflow / 🔍 🐹 Go Tests (push) Successful in 3m50s

This commit is contained in:
2025-06-10 08:36:02 -04:00
parent d1dc5897c5
commit 45b33d1ad8
6 changed files with 57 additions and 57 deletions

View File

@@ -1,6 +1,7 @@
package handlers
import (
"fmt"
"github.com/google/uuid"
"github.com/jackc/pgx/v5/pgtype"
"github.com/labstack/echo/v4"
@@ -23,7 +24,7 @@ func ParseUuidOrEmpty(s string) *pgtype.UUID {
func ParseUuid(s string) (*pgtype.UUID, error) {
uid, err := uuid.Parse(s)
if err != nil {
return nil, err
return nil, fmt.Errorf("invalid UUID format: %v", err)
}
return &pgtype.UUID{
@@ -32,13 +33,11 @@ func ParseUuid(s string) (*pgtype.UUID, error) {
}, nil
}
func ParseUuidOrBadRequest(c echo.Context, s string) *pgtype.UUID {
func ParseUuidOrBadRequest(c echo.Context, s string) (*pgtype.UUID, error) {
uid, err := ParseUuid(s)
if err != nil {
_ = BadRequest(c, "Invalid UUID.")
return nil
return nil, BadRequest(c, fmt.Sprintf("invalid UUID. %v", err))
}
return uid
return uid, nil
}