javascript/node/selenium-webdriver/lib/error.js
function checkLegacyResponse(responseObj) {
  // Handle the legacy Selenium error response format.
  if (responseObj
      && typeof responseObj === 'object'
      && typeof responseObj['status'] === 'number'
      && responseObj['status'] !== 0) {
    let status = responseObj['status'];
    let ctor = LEGACY_ERROR_CODE_TO_TYPE.get(status) || WebDriverError;

    let value = responseObj['value'];

    if (!value || typeof value !== 'object') {
      throw new ctor(value + '');
    } else {
      let message = value['message'] + '';
      if (ctor !== UnexpectedAlertOpenError) {
        throw new ctor(message);
      }

      let text = '';
      if (value['alert'] && typeof value['alert']['text'] === 'string') {
        text = value['alert']['text'];
      }
      throw new UnexpectedAlertOpenError(message, text);
    }
  }
  return responseObj;
}
function checkLegacyResponse(responseObj) {
  // Handle the legacy Selenium error response format.
  if (responseObj
      && typeof responseObj === 'object'
      && typeof responseObj['status'] === 'number'
      && responseObj['status'] !== 0) {
    let status = responseObj['status'];
    let ctor = LEGACY_ERROR_CODE_TO_TYPE.get(status) || WebDriverError;

    let value = responseObj['value'];

    if (!value || typeof value !== 'object') {
      throw new ctor(value + '');
    } else {
      let message = value['message'] + '';
      if (ctor !== UnexpectedAlertOpenError) {
        throw new ctor(message);
      }

      let text = '';
      if (value['alert'] && typeof value['alert']['text'] === 'string') {
        text = value['alert']['text'];
      }
      throw new UnexpectedAlertOpenError(message, text);
    }
  }
  return responseObj;
}
function checkLegacyResponse ( responseObj ) { // Handle the legacy Selenium error response format. if ( responseObj && typeof responseObj === 'object' && typeof responseObj [ 'status' ] === 'number' && responseObj [ 'status' ] !== 0 ) { let status = responseObj [ 'status' ] ; let ctor = LEGACY_ERROR_CODE_TO_TYPE . get ( status ) || WebDriverError ; let value = responseObj [ 'value' ] ; if ( ! value || typeof value !== 'object' ) { throw new ctor ( value + '' ) ; } else { let message = value [ 'message' ] + '' ; if ( ctor !== UnexpectedAlertOpenError ) { throw new ctor ( message ) ; } let text = '' ; if ( value [ 'alert' ] && typeof value [ 'alert' ] [ 'text' ] === 'string' ) { text = value [ 'alert' ] [ 'text' ] ; } throw new UnexpectedAlertOpenError ( message , text ) ; } } return responseObj ; }
Checks a legacy response from the Selenium 2.0 wire protocol for an error.
@param {*} responseObj the response object to check.
@return {*} responseObj the original response if it does not define an error.
@throws {WebDriverError} if the response object defines an error.
Checks a legacy response from the Selenium 2 . 0 wire protocol for an error .