return error from patch method

This commit is contained in:
filifa 2024-07-11 22:46:24 -05:00
parent bf7b45bcc6
commit 20a0b66e5b
2 changed files with 6 additions and 5 deletions

View File

@ -102,12 +102,10 @@ func patch(obj any, path string, value any) error {
return err
}
func (f *FeedResponse) Patch(instr *instruction) {
func (f *FeedResponse) Patch(instr *instruction) error {
// TODO: need to handle each type of instruction separately: add,
// replace, remove, copy, move
log.Println("updating", instr.Path)
err := patch(map[string]any(*f), instr.Path, instr.Value)
if err != nil {
log.Println(err)
}
return err
}

View File

@ -80,7 +80,10 @@ func main() {
} else {
for _, patch := range patches {
for _, instr := range patch.Diff {
feed.Patch(&instr)
err = feed.Patch(&instr)
if err != nil {
log.Println(err)
}
}
}
}