javascript/node/selenium-webdriver/lib/error.js
function throwDecodedError(data) {
  if (isErrorResponse(data)) {
    let ctor = ERROR_CODE_TO_TYPE.get(data.error) || WebDriverError;
    let err = new ctor(data.message);
    // TODO(jleyba): remove whichever case is excluded from the final W3C spec.
    if (typeof data.stacktrace === 'string') {
      err.remoteStacktrace = data.stacktrace;
    } else if (typeof data.stackTrace === 'string') {
      err.remoteStacktrace = data.stackTrace;
    }
    throw err;
  }
  throw new WebDriverError('Unknown error: ' + JSON.stringify(data));
}
function throwDecodedError(data) {
  if (isErrorResponse(data)) {
    let ctor = ERROR_CODE_TO_TYPE.get(data.error) || WebDriverError;
    let err = new ctor(data.message);
    // TODO(jleyba): remove whichever case is excluded from the final W3C spec.
    if (typeof data.stacktrace === 'string') {
      err.remoteStacktrace = data.stacktrace;
    } else if (typeof data.stackTrace === 'string') {
      err.remoteStacktrace = data.stackTrace;
    }
    throw err;
  }
  throw new WebDriverError('Unknown error: ' + JSON.stringify(data));
}
function throwDecodedError ( data ) { if ( isErrorResponse ( data ) ) { let ctor = ERROR_CODE_TO_TYPE . get ( data . error ) || WebDriverError ; let err = new ctor ( data . message ) ; // TODO(jleyba): remove whichever case is excluded from the final W3C spec. if ( typeof data . stacktrace === 'string' ) { err . remoteStacktrace = data . stacktrace ; } else if ( typeof data . stackTrace === 'string' ) { err . remoteStacktrace = data . stackTrace ; } throw err ; } throw new WebDriverError ( 'Unknown error: ' + JSON . stringify ( data ) ) ; }
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/webdriver-spec.html#protocol
Throws an error coded from the W3C protocol . A generic error will be thrown if the provided data is not a valid encoded error .