src/back/models/errors.js
function EntityNotFoundError(entity, innerError) {
  /**
   * The name of the entity that was not found.
   * @type {?string}
   */
  this.entity = entity;
  /**
   * The inner error that generated the current error.
   * @type {?Error}
   */
  this.innerError = innerError;

  expect(arguments).to.have.length.below(
    3,
    'Invalid arguments length when creating a new EntityNotFoundError (it ' +
    'has to be passed less than 3 arguments)'
  );

  this.name = 'EntityNotFoundError';

  this.message = 'Cannot find Entity';
  if (entity) {
    expect(entity).to.be.a(
      'string',
      'Invalid argument "entity" when creating a new EntityNotFoundError ' +
      '(it has to be a string)'
    );
    this.message += ' "' + entity + '"';
  }

  this.stack = (new Error(this.message)).stack;
  if (innerError) {
    expect(innerError).to.be.an.instanceof(
      Error,
      'Invalid argument "innerError" when creating a new EntityNotFoundError ' +
      '(it has to be an Error)'
    );
    this.stack += '\n\n' + innerError.stack;
  }
}
function EntityNotFoundError(entity, innerError) {
  /**
   * The name of the entity that was not found.
   * @type {?string}
   */
  this.entity = entity;
  /**
   * The inner error that generated the current error.
   * @type {?Error}
   */
  this.innerError = innerError;

  expect(arguments).to.have.length.below(
    3,
    'Invalid arguments length when creating a new EntityNotFoundError (it ' +
    'has to be passed less than 3 arguments)'
  );

  this.name = 'EntityNotFoundError';

  this.message = 'Cannot find Entity';
  if (entity) {
    expect(entity).to.be.a(
      'string',
      'Invalid argument "entity" when creating a new EntityNotFoundError ' +
      '(it has to be a string)'
    );
    this.message += ' "' + entity + '"';
  }

  this.stack = (new Error(this.message)).stack;
  if (innerError) {
    expect(innerError).to.be.an.instanceof(
      Error,
      'Invalid argument "innerError" when creating a new EntityNotFoundError ' +
      '(it has to be an Error)'
    );
    this.stack += '\n\n' + innerError.stack;
  }
}
function EntityNotFoundError ( entity , innerError ) { /**
   * The name of the entity that was not found.
   * @type {?string}
   */ this . entity = entity ; /**
   * The inner error that generated the current error.
   * @type {?Error}
   */ this . innerError = innerError ; expect ( arguments ) . to . have . length . below ( 3 , 'Invalid arguments length when creating a new EntityNotFoundError (it ' + 'has to be passed less than 3 arguments)' ) ; this . name = 'EntityNotFoundError' ; this . message = 'Cannot find Entity' ; if ( entity ) { expect ( entity ) . to . be . a ( 'string' , 'Invalid argument "entity" when creating a new EntityNotFoundError ' + '(it has to be a string)' ) ; this . message += ' "' + entity + '"' ; } this . stack = ( new Error ( this . message ) ) . stack ; if ( innerError ) { expect ( innerError ) . to . be . an . instanceof ( Error , 'Invalid argument "innerError" when creating a new EntityNotFoundError ' + '(it has to be an Error)' ) ; this . stack += '\n\n' + innerError . stack ; } }
Error class to be used when an Entity was referenced and the platform was not
able to find it.
@constructor
@extends Error
@param {?string} [entity] The entity name to be displayed.
@param {?Error} [innerError] The inner error.
@memberof module:back4app-entity/models/errors
@example
try {
var myEntity = require('./MyEntity');
}
catch (e) {
throw new EntityNotFoundError('MyEntity', e);
}
Error class to be used when an Entity was referenced and the platform was not able to find it .