Skip to content

Commit

Permalink
try to be a bit more friendly
Browse files Browse the repository at this point in the history
Signed-off-by: Doug Davis <[email protected]>
  • Loading branch information
duglin committed Jan 6, 2025
1 parent 7ca966a commit 0399d99
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions registry/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,19 +372,22 @@ func Unmarshal(buf []byte, v any) error {
// Try to grab the json around the error
offset := int(dec.InputOffset())
nearStart := offset - 200
// lineNum := LineNum(buf, int(offset))
if nearStart < 0 {
nearStart = 0
}
nearEnd := offset + 200
if nearEnd >= len(buf) {
nearEnd = len(buf)
}
near := ""
near := "" // fmt.Sprintf(" near: ") // line #%d\n", lineNum)
// log.Printf("offset: %d len(buf): %d, nearStart: %d", offset, len(buf), nearStart)
// log.Printf("** %s", buf[offset:])
if nearStart != offset {
if nearStart != 0 {
near = "..."
near += "..."
}
near = string(buf[nearStart:nearEnd])
near += string(buf[nearStart:nearEnd])
}
if offset > 0 && nearEnd != offset {
near += "..."
Expand Down Expand Up @@ -450,6 +453,7 @@ func ProcessIncludes(file string, buf []byte, localFiles bool) ([]byte, error) {
}

// Convert back to byte
// buf, err := json.MarshalIndent(data, "", " ")
buf, err := json.Marshal(data)
if err != nil {
return nil, fmt.Errorf("Error generating JSON: %s", err)
Expand Down

0 comments on commit 0399d99

Please sign in to comment.