AppErrors.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /**
  2. * Created by benzhan on 15/8/25.
  3. */
  4. var util = require('util');
  5. function AbstractError(msg, constr) {
  6. Error.captureStackTrace(this, constr || this);
  7. this.message = msg || 'Error'
  8. }
  9. util.inherits(AbstractError, Error);
  10. AbstractError.prototype.name = 'Abstract Error';
  11. /**
  12. * 中断(正常停止)
  13. * @param msg
  14. * @constructor
  15. */
  16. function Interrupt(msg) {
  17. Interrupt.super_.call(this, msg, this.constructor)
  18. }
  19. util.inherits(Interrupt, AbstractError);
  20. Interrupt.prototype.name = 'Interrupt';
  21. /**
  22. * 数据库错误
  23. * @param msg
  24. * @constructor
  25. */
  26. function DbError(msg) {
  27. DbError.super_.call(this, msg, this.constructor)
  28. }
  29. util.inherits(DbError, AbstractError);
  30. DbError.prototype.name = 'Database Error';
  31. /**
  32. * Redis错误
  33. * @param msg
  34. * @constructor
  35. */
  36. function RedisError(msg) {
  37. RedisError.super_.call(this, msg, this.constructor)
  38. }
  39. util.inherits(RedisError, AbstractError);
  40. RedisError.prototype.name = 'Redis Error';
  41. module.exports = {
  42. Interrupt: Interrupt,
  43. DbError: DbError,
  44. RedisError: RedisError
  45. };