handle out-of-range panic
This commit is contained in:
parent
def18e04e2
commit
0cd2bcd4e9
|
@ -76,7 +76,15 @@ func patch(obj any, path string, value any) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
// FIXME: think i need to do bounds checking here too
|
|
||||||
|
if len(v) <= idx {
|
||||||
|
arr := make([]any, idx+1)
|
||||||
|
for i, val := range v {
|
||||||
|
arr[i] = val
|
||||||
|
}
|
||||||
|
v = arr
|
||||||
|
}
|
||||||
|
|
||||||
err = patch(v[idx], rest, value)
|
err = patch(v[idx], rest, value)
|
||||||
default:
|
default:
|
||||||
err = errors.New("couldn't determine type")
|
err = errors.New("couldn't determine type")
|
||||||
|
|
Loading…
Reference in New Issue