You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.0 KiB

4 years ago
  1. 'use strict'
  2. const assert = require('assert')
  3. class RedisError extends Error {
  4. get name () {
  5. return this.constructor.name
  6. }
  7. }
  8. class ParserError extends RedisError {
  9. constructor (message, buffer, offset) {
  10. assert(buffer)
  11. assert.strictEqual(typeof offset, 'number')
  12. const tmp = Error.stackTraceLimit
  13. Error.stackTraceLimit = 2
  14. super(message)
  15. Error.stackTraceLimit = tmp
  16. this.offset = offset
  17. this.buffer = buffer
  18. }
  19. get name () {
  20. return this.constructor.name
  21. }
  22. }
  23. class ReplyError extends RedisError {
  24. constructor (message) {
  25. const tmp = Error.stackTraceLimit
  26. Error.stackTraceLimit = 2
  27. super(message)
  28. Error.stackTraceLimit = tmp
  29. }
  30. get name () {
  31. return this.constructor.name
  32. }
  33. }
  34. class AbortError extends RedisError {
  35. get name () {
  36. return this.constructor.name
  37. }
  38. }
  39. class InterruptError extends AbortError {
  40. get name () {
  41. return this.constructor.name
  42. }
  43. }
  44. module.exports = {
  45. RedisError,
  46. ParserError,
  47. ReplyError,
  48. AbortError,
  49. InterruptError
  50. }