remove json boilerplate, log error and return response
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 2m45s

This commit is contained in:
2026-03-04 15:58:14 +00:00
parent 88884121ab
commit 190bc6076b

View File

@@ -6,6 +6,7 @@ import (
"encoding/json" "encoding/json"
"io" "io"
"net/http" "net/http"
"strings"
"time" "time"
"github.com/rwcarlsen/goexif/exif" "github.com/rwcarlsen/goexif/exif"
@@ -122,9 +123,21 @@ No text, no markdown, no explanation. Just the JSON object.`),
} }
extractedData := ExtractedRowingData{} extractedData := ExtractedRowingData{}
err = json.Unmarshal([]byte(message.Content[0].Text), &extractedData) raw := message.Content[0].Text
raw = strings.TrimSpace(raw)
raw = strings.TrimPrefix(raw, "```json")
raw = strings.TrimPrefix(raw, "```")
raw = strings.TrimSuffix(raw, "```")
raw = strings.TrimSpace(raw)
err = json.Unmarshal([]byte(raw), &extractedData)
if err != nil { if err != nil {
ctx.JSON(http.StatusInternalServerError, gin.H{"error": "failed to parse JSON response"}) ctx.JSON(http.StatusInternalServerError, gin.H{
"error": "failed to parse JSON response",
"detail": err.Error(),
"raw": raw,
})
return return
} }