mock-errors.js 707 B

1234567891011121314151617181920212223242526272829
  1. 'use strict'
  2. const { UndiciError } = require('../core/errors')
  3. const kMockNotMatchedError = Symbol.for('undici.error.UND_MOCK_ERR_MOCK_NOT_MATCHED')
  4. /**
  5. * The request does not match any registered mock dispatches.
  6. */
  7. class MockNotMatchedError extends UndiciError {
  8. constructor (message) {
  9. super(message)
  10. this.name = 'MockNotMatchedError'
  11. this.message = message || 'The request does not match any registered mock dispatches'
  12. this.code = 'UND_MOCK_ERR_MOCK_NOT_MATCHED'
  13. }
  14. static [Symbol.hasInstance] (instance) {
  15. return instance && instance[kMockNotMatchedError] === true
  16. }
  17. get [kMockNotMatchedError] () {
  18. return true
  19. }
  20. }
  21. module.exports = {
  22. MockNotMatchedError
  23. }