summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2022-11-02 21:56:33 +0000
committerLinus Groh <mail@linusgroh.de>2022-11-02 23:46:30 +0000
commit6e1131e6dee6d0c8f87d835f8e97524b410c731a (patch)
tree4395147a69a39b460324053fea57f8b373b5d961 /Userland
parent747ba2a88f14cd52500f99e09d4b977200a6e75e (diff)
downloadserenity-6e1131e6dee6d0c8f87d835f8e97524b410c731a.zip
WebDriver: Support "data" field in error responses
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Services/WebDriver/Client.cpp2
-rw-r--r--Userland/Services/WebDriver/WebDriverError.cpp11
-rw-r--r--Userland/Services/WebDriver/WebDriverError.h4
3 files changed, 11 insertions, 6 deletions
diff --git a/Userland/Services/WebDriver/Client.cpp b/Userland/Services/WebDriver/Client.cpp
index 03df19b339..d6f477b3be 100644
--- a/Userland/Services/WebDriver/Client.cpp
+++ b/Userland/Services/WebDriver/Client.cpp
@@ -229,6 +229,8 @@ ErrorOr<void> Client::send_error_response(WebDriverError const& error, HTTP::Htt
result.set("error", error.error);
result.set("message", error.message);
result.set("stacktrace", "");
+ if (error.data.has_value())
+ result.set("data", *error.data);
StringBuilder content_builder;
result.serialize(content_builder);
diff --git a/Userland/Services/WebDriver/WebDriverError.cpp b/Userland/Services/WebDriver/WebDriverError.cpp
index faf203bda1..8d51e10700 100644
--- a/Userland/Services/WebDriver/WebDriverError.cpp
+++ b/Userland/Services/WebDriver/WebDriverError.cpp
@@ -47,13 +47,14 @@ static Vector<ErrorCodeData> const s_error_code_data = {
{ ErrorCode::UnsupportedOperation, 500, "unsupported operation" },
};
-WebDriverError WebDriverError::from_code(ErrorCode code, String message)
+WebDriverError WebDriverError::from_code(ErrorCode code, String message, Optional<JsonValue> data)
{
- auto& data = s_error_code_data[to_underlying(code)];
+ auto const& error_code_data = s_error_code_data[to_underlying(code)];
return {
- .http_status = data.http_status,
- .error = data.json_error_code,
- .message = move(message)
+ .http_status = error_code_data.http_status,
+ .error = error_code_data.json_error_code,
+ .message = move(message),
+ .data = move(data)
};
}
diff --git a/Userland/Services/WebDriver/WebDriverError.h b/Userland/Services/WebDriver/WebDriverError.h
index a89deea587..bd05d6fa80 100644
--- a/Userland/Services/WebDriver/WebDriverError.h
+++ b/Userland/Services/WebDriver/WebDriverError.h
@@ -7,6 +7,7 @@
#pragma once
+#include <AK/JsonValue.h>
#include <AK/String.h>
namespace WebDriver {
@@ -48,8 +49,9 @@ struct WebDriverError {
unsigned http_status;
String error;
String message;
+ Optional<JsonValue> data;
- static WebDriverError from_code(ErrorCode, String message);
+ static WebDriverError from_code(ErrorCode, String message, Optional<JsonValue> data = {});
};
}