database-error.js 716 B

12345678910111213141516171819202122232425262728293031323334
  1. 'use strict';
  2. const BaseError = require('./base-error');
  3. /**
  4. * A base class for all database related errors.
  5. */
  6. class DatabaseError extends BaseError {
  7. constructor(parent) {
  8. super(parent.message);
  9. this.name = 'SequelizeDatabaseError';
  10. /**
  11. * @type {Error}
  12. */
  13. this.parent = parent;
  14. /**
  15. * @type {Error}
  16. */
  17. this.original = parent;
  18. /**
  19. * The SQL that triggered the error
  20. * @type {string}
  21. */
  22. this.sql = parent.sql;
  23. /**
  24. * The parameters for the sql that triggered the error
  25. * @type {Array<any>}
  26. */
  27. this.parameters = parent.parameters;
  28. Error.captureStackTrace(this, this.constructor);
  29. }
  30. }
  31. module.exports = DatabaseError;