1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-10 01:51:03 +09:00

LibDevTools: Add a helper to acquire required message parameters

This is just to help make the message handlers a bit briefer. I had
considered adding a TRY-like macro to auto-return when the lookup fails,
but since statement expressions cannot return references, that would
result in a copy of all e.g. object and array lookups.
This commit is contained in:
Timothy Flynn 2025-03-11 09:05:01 -04:00 committed by Tim Flynn
parent 4ce10f3bf4
commit e1ed8722e0
Notes: github-actions[bot] 2025-03-12 16:49:03 +00:00
12 changed files with 85 additions and 121 deletions

View file

@ -27,11 +27,9 @@ void TargetConfigurationActor::handle_message(StringView type, JsonObject const&
JsonObject response;
if (type == "updateConfiguration"sv) {
auto configuration = message.get_object("configuration"sv);
if (!configuration.has_value()) {
send_missing_parameter_error("configuration"sv);
auto configuration = get_required_parameter<JsonObject>(message, "configuration"sv);
if (!configuration.has_value())
return;
}
send_message(move(response));
return;