src/api/v4/error-handling/carto-error-extender.js
function _getListedError (cartoError, errorList) {
  var errorListkeys = _.keys(errorList);
  var key;
  for (var i = 0; i < errorListkeys.length; i++) {
    key = errorListkeys[i];
    if (!(errorList[key].messageRegex instanceof RegExp)) {
      throw new Error('MessageRegex on ' + key + ' is not a RegExp.');
    }
    if (errorList[key].messageRegex.test(cartoError.message)) {
      return {
        friendlyMessage: _replaceRegex(cartoError, errorList[key]),
        errorCode: _buildErrorCode(cartoError, key)
      };
    }
  }

  // When cartoError not found return generic values
  return {
    friendlyMessage: cartoError.message || '',
    errorCode: _buildErrorCode(cartoError, 'unknown-error')
  };
}
function _getListedError (cartoError, errorList) {
  var errorListkeys = _.keys(errorList);
  var key;
  for (var i = 0; i < errorListkeys.length; i++) {
    key = errorListkeys[i];
    if (!(errorList[key].messageRegex instanceof RegExp)) {
      throw new Error('MessageRegex on ' + key + ' is not a RegExp.');
    }
    if (errorList[key].messageRegex.test(cartoError.message)) {
      return {
        friendlyMessage: _replaceRegex(cartoError, errorList[key]),
        errorCode: _buildErrorCode(cartoError, key)
      };
    }
  }

  // When cartoError not found return generic values
  return {
    friendlyMessage: cartoError.message || '',
    errorCode: _buildErrorCode(cartoError, 'unknown-error')
  };
}
function _getListedError ( cartoError , errorList ) { var errorListkeys = _ . keys ( errorList ) ; var key ; for ( var i = 0 ; i < errorListkeys . length ; i ++ ) { key = errorListkeys [ i ] ; if ( ! ( errorList [ key ] . messageRegex instanceof RegExp ) ) { throw new Error ( 'MessageRegex on ' + key + ' is not a RegExp.' ) ; } if ( errorList [ key ] . messageRegex . test ( cartoError . message ) ) { return { friendlyMessage : _replaceRegex ( cartoError , errorList [ key ] ) , errorCode : _buildErrorCode ( cartoError , key ) } ; } } // When cartoError not found return generic values return { friendlyMessage : cartoError . message || '' , errorCode : _buildErrorCode ( cartoError , 'unknown-error' ) } ; }
Get the listed error from a cartoError, if no listedError is found return a generic
unknown error.
@param {CartoError} cartoError
Get the listed error from a cartoError if no listedError is found return a generic unknown error .