database-error.js 677 B

1234567891011121314151617181920212223242526272829303132333435
  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. *
  21. * @type {string}
  22. */
  23. this.sql = parent.sql;
  24. /**
  25. * The parameters for the sql that triggered the error
  26. *
  27. * @type {Array<any>}
  28. */
  29. this.parameters = parent.parameters;
  30. }
  31. }
  32. module.exports = DatabaseError;