MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / decode

Method decode

java/src/org/openqa/selenium/remote/ErrorCodec.java:149–173  ·  view source on GitHub ↗
(Map<String, Object> response)

Source from the content-addressed store, hash-verified

147 }
148
149 public WebDriverException decode(Map<String, Object> response) {
150 if (!(response.get("value") instanceof Map)) {
151 throw new InvalidResponseException("missing \"value\" field", response);
152 }
153
154 Map<?, ?> value = (Map<?, ?>) response.get("value");
155
156 Object error = requireNonNullElse(value.get("error"), "");
157 Object message = requireNonNullElseGet(value.get("message"), response::toString);
158
159 if (!(error instanceof String)) {
160 throw new InvalidResponseException("\"error\" field must be a string", response);
161 }
162 if (!(message instanceof String)) {
163 throw new InvalidResponseException("\"message\" field must be a string", response);
164 }
165
166 Optional<W3CError<? extends WebDriverException>> w3CError =
167 ERRORS.stream().filter(err -> error.equals(err.w3cErrorString)).findFirst();
168 if (w3CError.isPresent()) {
169 return w3CError.get().exceptionConstructor.apply((String) message);
170 }
171 String extendedMessage = String.format("%s (error code: \"%s\")", message, error);
172 return DEFAULT_ERROR.exceptionConstructor.apply(extendedMessage);
173 }
174
175 private W3CError<? extends WebDriverException> fromThrowable(Throwable throwable) {
176 return ERRORS.stream()

Callers

nothing calls this directly

Calls 7

filterMethod · 0.80
getMethod · 0.65
isPresentMethod · 0.65
streamMethod · 0.45
equalsMethod · 0.45
applyMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected