code: function CartoError (error, opts) {
    opts = opts || {};
    var cartoError = Object.create(Error.prototype);
    cartoError.message = (error && error.message) || UNEXPECTED_ERROR;
    cartoError.origin = (error && error.origin) || GENERIC_ORIGIN;
    cartoError.type = (error && error.type) || '';
  
    if (_isWindshaftError(error)) {
      cartoError = _transformWindshaftError(error, opts.layers, opts.analysis);
    }
  
    if (_isAjaxError(error)) {
      cartoError = _transformAjaxError(error);
    }
  
    // Add extra fields
    var extraFields = errorExtender.getExtraFields(cartoError);
    cartoError.message = extraFields.friendlyMessage;
    cartoError.errorCode = extraFields.errorCode;
  
    // Final properties
    cartoError.name = 'CartoError';
    cartoError.stack = (new Error()).stack;
    cartoError.originalError = error;
  
    errorTracker.track(cartoError);
  
    return cartoError;
  }
docs: Build a cartoError from a generic error.
  @constructor
  
  @return {CartoError} A well formed object representing the error.