* Throws an error coded from the W3C protocol. A generic error will be thrown * if the provided `data` is not a valid encoded error. * * @param {{error: string, message: string}} data The error data to decode. * @throws {WebDriverError} the decoded error. * @see https://w3c.github.io/webdriver/
(data)
| 518 | * @see https://w3c.github.io/webdriver/webdriver-spec.html#protocol |
| 519 | */ |
| 520 | function throwDecodedError(data) { |
| 521 | if (isErrorResponse(data)) { |
| 522 | let ctor = ERROR_CODE_TO_TYPE.get(data.error) || WebDriverError |
| 523 | let err = new ctor(data.message) |
| 524 | // TODO(jleyba): remove whichever case is excluded from the final W3C spec. |
| 525 | if (typeof data.stacktrace === 'string') { |
| 526 | err.remoteStacktrace = data.stacktrace |
| 527 | } else if (typeof data.stackTrace === 'string') { |
| 528 | err.remoteStacktrace = data.stackTrace |
| 529 | } |
| 530 | throw err |
| 531 | } |
| 532 | throw new WebDriverError('Unknown error: ' + JSON.stringify(data)) |
| 533 | } |
| 534 | |
| 535 | /** |
| 536 | * Checks a legacy response from the Selenium 2.0 wire protocol for an error. |
nothing calls this directly
no test coverage detected