exceptions.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. const { PACKAGE_NAME } = require('./config');
  2. class LoaderException extends Error {
  3. constructor(message = '') {
  4. super(`${PACKAGE_NAME} exception. ${message}`);
  5. this.name = this.constructor.name;
  6. /* istanbul ignore else */
  7. if (typeof Error.captureStackTrace === 'function') {
  8. Error.captureStackTrace(this, this.constructor);
  9. } else {
  10. this.stack = (new Error(message)).stack;
  11. }
  12. }
  13. }
  14. class InvalidSvg extends LoaderException {
  15. constructor(content) {
  16. super(`\n\n${content}`);
  17. }
  18. }
  19. class ExtractPluginMissingException extends LoaderException {
  20. constructor() {
  21. super(`${PACKAGE_NAME} in extract mode requires the corresponding plugin`);
  22. }
  23. }
  24. class InvalidRuntimeException extends LoaderException {}
  25. class RemainingLoadersInExtractModeException extends LoaderException {
  26. constructor() {
  27. super(`Some loaders will be applied after ${PACKAGE_NAME} in extract mode`);
  28. }
  29. }
  30. exports.LoaderException = LoaderException;
  31. exports.InvalidSvg = InvalidSvg;
  32. exports.ExtractPluginMissingException = ExtractPluginMissingException;
  33. exports.InvalidRuntimeException = InvalidRuntimeException;
  34. exports.RemainingLoadersInExtractModeException = RemainingLoadersInExtractModeException;