sqlite-error.js 717 B

1234567891011121314151617181920
  1. 'use strict';
  2. const descriptor = { value: 'SqliteError', writable: true, enumerable: false, configurable: true };
  3. function SqliteError(message, code) {
  4. if (new.target !== SqliteError) {
  5. return new SqliteError(message, code);
  6. }
  7. if (typeof code !== 'string') {
  8. throw new TypeError('Expected second argument to be a string');
  9. }
  10. Error.call(this, message);
  11. descriptor.value = '' + message;
  12. Object.defineProperty(this, 'message', descriptor);
  13. Error.captureStackTrace(this, SqliteError);
  14. this.code = code;
  15. }
  16. Object.setPrototypeOf(SqliteError, Error);
  17. Object.setPrototypeOf(SqliteError.prototype, Error.prototype);
  18. Object.defineProperty(SqliteError.prototype, 'name', descriptor);
  19. module.exports = SqliteError;