lib/tools/index.js
function (err) {
    "use strict";

    var message = '';

    if (typeof err === 'string') {
      return new Error(err);

    } else if (typeof err === 'object') {

      if (err.cause) {
        // probably a webdriver error
        try {
          message = JSON.parse(err.cause.value.message).errorMessage;
        } catch ($) {
          message = err.cause.value.message;
        }
      } else {
        message = err.message || err.toString();
      }
      return new Error(message);
    }
    return new Error(err.toString());
  }
function (err) {
    "use strict";

    var message = '';

    if (typeof err === 'string') {
      return new Error(err);

    } else if (typeof err === 'object') {

      if (err.cause) {
        // probably a webdriver error
        try {
          message = JSON.parse(err.cause.value.message).errorMessage;
        } catch ($) {
          message = err.cause.value.message;
        }
      } else {
        message = err.message || err.toString();
      }
      return new Error(message);
    }
    return new Error(err.toString());
  }
function ( err ) { "use strict" ; var message = '' ; if ( typeof err === 'string' ) { return new Error ( err ) ; } else if ( typeof err === 'object' ) { if ( err . cause ) { // probably a webdriver error try { message = JSON . parse ( err . cause . value . message ) . errorMessage ; } catch ( $ ) { message = err . cause . value . message ; } } else { message = err . message || err . toString ( ) ; } return new Error ( message ) ; } return new Error ( err . toString ( ) ) ; }
Make an error comming from webdriver a little more readable.
Make an error comming from webdriver a little more readable .