summaryrefslogtreecommitdiff
path: root/Kernel/kstdio.h
diff options
context:
space:
mode:
authorGunnar Beutner <gbeutner@serenityos.org>2022-10-31 19:22:14 +0100
committerLinus Groh <mail@linusgroh.de>2022-11-01 11:57:08 +0000
commitd1bc157e9f251141d026d612171776c33853ec10 (patch)
treeb81f6021b6a58d42d80c690b6915dc1785f4f528 /Kernel/kstdio.h
parent92efa217277b105bf23e010eccff289c900f3785 (diff)
downloadserenity-d1bc157e9f251141d026d612171776c33853ec10.zip
AK: Allow destruction of JsonObjectSerializer objects after errors
Previously we'd VERIFY() that the user had called finish(). This makes the following code incorrect though: auto json = TRY(JsonObjectSerializer<>::try_create(builder)); TRY(json.add("total_time"sv, total_time_scheduled.total)); TRY(json.finish()); return ...; If the second TRY() returns early we'd fail at the VERIFY() call in the destructor. Calling finish() in the destructor - like we had done earlier - is also not helpful because we have no idea whether the builder is still valid. Plus we wouldn't be able to handle any errors for that call. Verifying that either finish() was called or an error occurred doesn't work either because the caller might have multiple Json*Serializer objects, e.g. when inserting a JSON array into a JSON object. Forcing the user to call finish() on their "main" object when a sub-object caused an error seems unnecessarily tedious.
Diffstat (limited to 'Kernel/kstdio.h')
0 files changed, 0 insertions, 0 deletions