getExceptionFromW3cResponse function
Temporary method to emulate the original w3c exception parsing logic.
Implementation
WebDriverException getExceptionFromW3cResponse({
int? httpStatusCode,
String? httpReasonPhrase,
Object? jsonResp,
}) {
if (jsonResp is Map && jsonResp.keys.contains('value')) {
final value = jsonResp['value'] as Map<String, Object?>;
return switch (value['error']) {
'invalid argument' => InvalidArgumentException(
httpStatusCode,
value['message'] as String?,
),
'no such element' => NoSuchElementException(
httpStatusCode,
value['message'] as String?,
),
_ => WebDriverException(httpStatusCode, value['message'] as String?),
};
}
return InvalidResponseException(httpStatusCode, jsonResp.toString());
}