| 297 | } |
| 298 | |
| 299 | public String toState(@Nullable Integer status) { |
| 300 | if (status == null) { |
| 301 | return toState(UNHANDLED_ERROR); |
| 302 | } |
| 303 | |
| 304 | if (SUCCESS == status) { |
| 305 | return SUCCESS_STRING; |
| 306 | } |
| 307 | |
| 308 | Set<String> possibleMatches = |
| 309 | KNOWN_ERRORS.stream() |
| 310 | .filter(knownError -> knownError.getJsonCode() == status) |
| 311 | .filter(KnownError::isCanonicalForW3C) |
| 312 | .map(KnownError::getW3cCode) |
| 313 | .collect(Collectors.toSet()); |
| 314 | |
| 315 | return onlyElement(possibleMatches, "unhandled error"); |
| 316 | } |
| 317 | |
| 318 | public int toStatus(String webdriverState, Optional<Integer> httpStatus) { |
| 319 | if (SUCCESS_STRING.equals(webdriverState)) { |