errors.js 953 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*!
  2. * Stylus - errors
  3. * Copyright (c) Automattic <developer.wordpress.com>
  4. * MIT Licensed
  5. */
  6. /**
  7. * Expose constructors.
  8. */
  9. exports.ParseError = ParseError;
  10. exports.SyntaxError = SyntaxError;
  11. /**
  12. * Inherit from `Error.prototype`.
  13. */
  14. SyntaxError.prototype.__proto__ = Error.prototype;
  15. /**
  16. * Initialize a new `ParseError` with the given `msg`.
  17. *
  18. * @param {String} msg
  19. * @api private
  20. */
  21. function ParseError(msg) {
  22. this.name = 'ParseError';
  23. this.message = msg;
  24. Error.captureStackTrace(this, ParseError);
  25. }
  26. /**
  27. * Inherit from `Error.prototype`.
  28. */
  29. ParseError.prototype.__proto__ = Error.prototype;
  30. /**
  31. * Initialize a new `SyntaxError` with the given `msg`.
  32. *
  33. * @param {String} msg
  34. * @api private
  35. */
  36. function SyntaxError(msg) {
  37. this.name = 'SyntaxError';
  38. this.message = msg;
  39. Error.captureStackTrace(this, ParseError);
  40. }
  41. /**
  42. * Inherit from `Error.prototype`.
  43. */
  44. SyntaxError.prototype.__proto__ = Error.prototype;