errors.js 934 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. * Initialize a new `ParseError` with the given `msg`.
  13. *
  14. * @param {String} msg
  15. * @api private
  16. */
  17. function ParseError(msg) {
  18. this.name = 'ParseError';
  19. this.message = msg;
  20. if (Error.captureStackTrace) {
  21. Error.captureStackTrace(this, ParseError);
  22. }
  23. }
  24. /**
  25. * Inherit from `Error.prototype`.
  26. */
  27. ParseError.prototype.__proto__ = Error.prototype;
  28. /**
  29. * Initialize a new `SyntaxError` with the given `msg`.
  30. *
  31. * @param {String} msg
  32. * @api private
  33. */
  34. function SyntaxError(msg) {
  35. this.name = 'SyntaxError';
  36. this.message = msg;
  37. if (Error.captureStackTrace) {
  38. Error.captureStackTrace(this, ParseError);
  39. }
  40. }
  41. /**
  42. * Inherit from `Error.prototype`.
  43. */
  44. SyntaxError.prototype.__proto__ = Error.prototype;