fix: log json marshal errors in ToJSON

This commit is contained in:
2026-04-21 01:21:08 +02:00
parent 420b7fa67a
commit bf9f12f191

View File

@@ -3,6 +3,7 @@ package shared
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"log"
"strconv" "strconv"
) )
@@ -66,7 +67,11 @@ func ModeToken(mode string, modeSources map[string]ModeSource) string {
} }
func ToJSON(v interface{}) string { func ToJSON(v interface{}) string {
b, _ := json.Marshal(v) b, err := json.Marshal(v)
if err != nil {
log.Printf("ToJSON error: %v", err)
return "{}"
}
return string(b) return string(b)
} }