mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:27:45 +00:00
WebDriver: Rename HttpError -> WebDriverError
This commit is contained in:
parent
87a9462b7f
commit
89c3e0b567
7 changed files with 220 additions and 219 deletions
|
@ -12,8 +12,8 @@
|
|||
#include <LibCore/Stream.h>
|
||||
#include <LibHTTP/Forward.h>
|
||||
#include <LibHTTP/HttpRequest.h>
|
||||
#include <WebDriver/HttpError.h>
|
||||
#include <WebDriver/Session.h>
|
||||
#include <WebDriver/WebDriverError.h>
|
||||
|
||||
namespace WebDriver {
|
||||
|
||||
|
@ -30,11 +30,11 @@ private:
|
|||
ErrorOr<JsonValue> read_body_as_json(HTTP::HttpRequest const&);
|
||||
ErrorOr<bool> handle_request(HTTP::HttpRequest const&, JsonValue const& body);
|
||||
ErrorOr<void> send_response(StringView content, HTTP::HttpRequest const&);
|
||||
ErrorOr<void> send_error_response(HttpError const& error, HTTP::HttpRequest const&);
|
||||
ErrorOr<void> send_error_response(WebDriverError const& error, HTTP::HttpRequest const&);
|
||||
void die();
|
||||
void log_response(unsigned code, HTTP::HttpRequest const&);
|
||||
|
||||
using RouteHandler = ErrorOr<JsonValue, HttpError> (Client::*)(Vector<StringView> const&, JsonValue const&);
|
||||
using RouteHandler = ErrorOr<JsonValue, WebDriverError> (Client::*)(Vector<StringView> const&, JsonValue const&);
|
||||
struct Route {
|
||||
HTTP::HttpRequest::Method method;
|
||||
Vector<String> path;
|
||||
|
@ -46,56 +46,56 @@ private:
|
|||
Vector<StringView> parameters;
|
||||
};
|
||||
|
||||
ErrorOr<RoutingResult, HttpError> match_route(HTTP::HttpRequest::Method method, String const& resource);
|
||||
ErrorOr<JsonValue, HttpError> handle_new_session(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, HttpError> handle_delete_session(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, HttpError> handle_get_status(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, HttpError> handle_get_timeouts(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, HttpError> handle_set_timeouts(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, HttpError> handle_navigate_to(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, HttpError> handle_get_current_url(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, HttpError> handle_back(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, HttpError> handle_forward(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, HttpError> handle_refresh(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, HttpError> handle_get_title(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, HttpError> handle_get_window_handle(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, HttpError> handle_close_window(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, HttpError> handle_get_window_handles(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, HttpError> handle_find_element(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, HttpError> handle_find_elements(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, HttpError> handle_find_element_from_element(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, HttpError> handle_find_elements_from_element(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, HttpError> handle_get_element_attribute(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, HttpError> handle_get_element_property(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, HttpError> handle_get_element_css_value(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, HttpError> handle_get_all_cookies(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, HttpError> handle_get_named_cookie(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, HttpError> handle_add_cookie(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, HttpError> handle_delete_cookie(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, HttpError> handle_delete_all_cookies(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<RoutingResult, WebDriverError> match_route(HTTP::HttpRequest::Method method, String const& resource);
|
||||
ErrorOr<JsonValue, WebDriverError> handle_new_session(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, WebDriverError> handle_delete_session(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, WebDriverError> handle_get_status(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, WebDriverError> handle_get_timeouts(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, WebDriverError> handle_set_timeouts(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, WebDriverError> handle_navigate_to(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, WebDriverError> handle_get_current_url(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, WebDriverError> handle_back(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, WebDriverError> handle_forward(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, WebDriverError> handle_refresh(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, WebDriverError> handle_get_title(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, WebDriverError> handle_get_window_handle(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, WebDriverError> handle_close_window(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, WebDriverError> handle_get_window_handles(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, WebDriverError> handle_find_element(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, WebDriverError> handle_find_elements(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, WebDriverError> handle_find_element_from_element(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, WebDriverError> handle_find_elements_from_element(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, WebDriverError> handle_get_element_attribute(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, WebDriverError> handle_get_element_property(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, WebDriverError> handle_get_element_css_value(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, WebDriverError> handle_get_all_cookies(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, WebDriverError> handle_get_named_cookie(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, WebDriverError> handle_add_cookie(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, WebDriverError> handle_delete_cookie(Vector<StringView> const&, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, WebDriverError> handle_delete_all_cookies(Vector<StringView> const&, JsonValue const& payload);
|
||||
|
||||
ErrorOr<Session*, HttpError> find_session_with_id(StringView session_id);
|
||||
ErrorOr<Session*, WebDriverError> find_session_with_id(StringView session_id);
|
||||
JsonValue make_json_value(JsonValue const&);
|
||||
|
||||
template<typename T>
|
||||
static ErrorOr<T, HttpError> unwrap_result(ErrorOr<T, Variant<HttpError, Error>> result)
|
||||
static ErrorOr<T, WebDriverError> unwrap_result(ErrorOr<T, Variant<WebDriverError, Error>> result)
|
||||
{
|
||||
if (result.is_error()) {
|
||||
Variant<HttpError, Error> error = result.release_error();
|
||||
if (error.has<HttpError>())
|
||||
return error.get<HttpError>();
|
||||
return HttpError { 500, "unsupported operation", error.get<Error>().string_literal() };
|
||||
Variant<WebDriverError, Error> error = result.release_error();
|
||||
if (error.has<WebDriverError>())
|
||||
return error.get<WebDriverError>();
|
||||
return WebDriverError { 500, "unsupported operation", error.get<Error>().string_literal() };
|
||||
}
|
||||
|
||||
return result.release_value();
|
||||
}
|
||||
static ErrorOr<void, HttpError> unwrap_result(ErrorOr<void, Variant<HttpError, Error>> result)
|
||||
static ErrorOr<void, WebDriverError> unwrap_result(ErrorOr<void, Variant<WebDriverError, Error>> result)
|
||||
{
|
||||
if (result.is_error()) {
|
||||
Variant<HttpError, Error> error = result.release_error();
|
||||
if (error.has<HttpError>())
|
||||
return error.get<HttpError>();
|
||||
return HttpError { 500, "unsupported operation", error.get<Error>().string_literal() };
|
||||
Variant<WebDriverError, Error> error = result.release_error();
|
||||
if (error.has<WebDriverError>())
|
||||
return error.get<WebDriverError>();
|
||||
return WebDriverError { 500, "unsupported operation", error.get<Error>().string_literal() };
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue