error.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright (c) 2014-2015 Sylvain Peyrefitte
  3. *
  4. * This file is part of node-rdpjs.
  5. *
  6. * node-rdpjs is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. var inherits = require('util').inherits;
  20. /**
  21. * Fatal error stop program
  22. */
  23. function FatalError(message, code) {
  24. Error.captureStackTrace(this);
  25. this.message = message || "";
  26. this.code = code || 'NODE_RDP_CORE_ERROR_NO_ERROR_CODE';
  27. }
  28. /**
  29. * inherit from error
  30. */
  31. inherits(FatalError, Error);
  32. /**
  33. * Protocol error (non fatal);
  34. */
  35. function ProtocolError(code, message) {
  36. Error.captureStackTrace(this);
  37. this.code = code;
  38. this.message = message || "";
  39. }
  40. /**
  41. * inherit from error
  42. */
  43. inherits(ProtocolError, Error);
  44. /**
  45. * ImplementationError error (non fatal);
  46. */
  47. function ImplementationError(code, message) {
  48. Error.captureStackTrace(this);
  49. this.code = code;
  50. this.message = message || "";
  51. }
  52. /**
  53. * inherit from error
  54. */
  55. inherits(ImplementationError, Error);
  56. /**
  57. * Module exports
  58. */
  59. module.exports = {
  60. FatalError : FatalError,
  61. ProtocolError : ProtocolError,
  62. ImplementationError : ImplementationError
  63. };