optimistic-lock-error.js 842 B

123456789101112131415161718192021222324252627282930313233
  1. 'use strict';
  2. const BaseError = require('./base-error');
  3. /**
  4. * Thrown when attempting to update a stale model instance
  5. */
  6. class OptimisticLockError extends BaseError {
  7. constructor(options) {
  8. options = options || {};
  9. options.message = options.message || `Attempting to update a stale model instance: ${options.modelName}`;
  10. super(options.message);
  11. this.name = 'SequelizeOptimisticLockError';
  12. /**
  13. * The name of the model on which the update was attempted
  14. * @type {string}
  15. */
  16. this.modelName = options.modelName;
  17. /**
  18. * The values of the attempted update
  19. * @type {object}
  20. */
  21. this.values = options.values;
  22. /**
  23. *
  24. * @type {object}
  25. */
  26. this.where = options.where;
  27. Error.captureStackTrace(this, this.constructor);
  28. }
  29. }
  30. module.exports = OptimisticLockError;