Commit d0da686e authored by Eric Myhre's avatar Eric Myhre

fix: quip: functions involving both callbacks and followups handle errors correctly.

If there's any furhter action to take after the callback, it's
necessary to recheck the error slot before taking that action;
and of course we definitely don't want to overwrite the error if one
had been set during the callback.

I wonder if it would ever be useful to have a variant of these
functions which *does* attempt to call `Finish`, etc, and thus still
build a partial tree at the end even if it stopped on error midway.
(Right now, if something stops midway, the final `Build` call will
panic, and tell you you haven't finished all the assemblers.)
It would be a bit more complicated though: we'd potentially need to
accumulate more than one error.  And in practice, when working on
schema'd data, it would often still result in invalid results
(anything other than optional fields, or type-level maps and lists,
will fail some other logical rule if not fully filled in), which
makes me wonder how often this would be useful.
parent bbb0cbf3
......@@ -71,6 +71,9 @@ func BuildMap(e *error, na ipld.NodeAssembler, sizeHint int64, fn func(ma ipld.M
return
}
fn(ma)
if *e != nil {
return
}
*e = ma.Finish()
}
......@@ -108,6 +111,9 @@ func BuildList(e *error, na ipld.NodeAssembler, sizeHint int64, fn func(la ipld.
return
}
fn(la)
if *e != nil {
return
}
*e = la.Finish()
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment