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.

58 lines
1.6 KiB

4 years ago
  1. 'use strict';
  2. var util = require('util');
  3. var assert = require('assert');
  4. var RedisError = require('redis-errors').RedisError;
  5. var ADD_STACKTRACE = false;
  6. function AbortError (obj, stack) {
  7. assert(obj, 'The options argument is required');
  8. assert.strictEqual(typeof obj, 'object', 'The options argument has to be of type object');
  9. Object.defineProperty(this, 'message', {
  10. value: obj.message || '',
  11. configurable: true,
  12. writable: true
  13. });
  14. if (stack || stack === undefined) {
  15. Error.captureStackTrace(this, AbortError);
  16. }
  17. for (var keys = Object.keys(obj), key = keys.pop(); key; key = keys.pop()) {
  18. this[key] = obj[key];
  19. }
  20. }
  21. function AggregateError (obj) {
  22. assert(obj, 'The options argument is required');
  23. assert.strictEqual(typeof obj, 'object', 'The options argument has to be of type object');
  24. AbortError.call(this, obj, ADD_STACKTRACE);
  25. Object.defineProperty(this, 'message', {
  26. value: obj.message || '',
  27. configurable: true,
  28. writable: true
  29. });
  30. Error.captureStackTrace(this, AggregateError);
  31. for (var keys = Object.keys(obj), key = keys.pop(); key; key = keys.pop()) {
  32. this[key] = obj[key];
  33. }
  34. }
  35. util.inherits(AbortError, RedisError);
  36. util.inherits(AggregateError, AbortError);
  37. Object.defineProperty(AbortError.prototype, 'name', {
  38. value: 'AbortError',
  39. configurable: true,
  40. writable: true
  41. });
  42. Object.defineProperty(AggregateError.prototype, 'name', {
  43. value: 'AggregateError',
  44. configurable: true,
  45. writable: true
  46. });
  47. module.exports = {
  48. AbortError: AbortError,
  49. AggregateError: AggregateError
  50. };