errors.js 487 B

123456789101112131415161718
  1. module.exports = class EventEmitterError extends Error {
  2. constructor (msg, code, fn = EventEmitterError, opts) {
  3. super(`${code}: ${msg}`, opts)
  4. this.code = code
  5. if (Error.captureStackTrace) {
  6. Error.captureStackTrace(this, fn)
  7. }
  8. }
  9. get name () {
  10. return 'EventEmitterError'
  11. }
  12. static OPERATION_ABORTED (cause, msg = 'Operation aborted') {
  13. return new EventEmitterError(msg, 'OPERATION_ABORTED', EventEmitterError.OPERATION_ABORTED, { cause })
  14. }
  15. }