exceptions.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. if (typeof Error.captureStackTrace === 'function') {
  7. Error.captureStackTrace(this, this.constructor);
  8. } else {
  9. this.stack = (new Error(message)).stack;
  10. }
  11. }
  12. }
  13. class ExtractPluginMissingException extends LoaderException {
  14. constructor() {
  15. super(`${PACKAGE_NAME} in extract mode requires the corresponding plugin`);
  16. }
  17. }
  18. class InvalidRuntimeException extends LoaderException {
  19. constructor(runtime) {
  20. super(`Runtime generator "${runtime}" not found`);
  21. }
  22. }
  23. class SeveralRulesAppliedException extends LoaderException {
  24. constructor(resource, rules) {
  25. super(`${rules.length} rules applies to ${resource}`);
  26. }
  27. }
  28. class RemainingLoadersInExtractModeException extends LoaderException {
  29. constructor() {
  30. super(`Some loaders will be applied after ${PACKAGE_NAME} in extract mode`);
  31. }
  32. }
  33. exports.LoaderException = LoaderException;
  34. exports.ExtractPluginMissingException = ExtractPluginMissingException;
  35. exports.InvalidRuntimeException = InvalidRuntimeException;
  36. exports.SeveralRulesAppliedException = SeveralRulesAppliedException;
  37. exports.RemainingLoadersInExtractModeException = RemainingLoadersInExtractModeException;