MCPcopy
hub / github.com/webpack/webpack / generateError

Method generateError

lib/css/CssGenerator.js:598–611  ·  view source on GitHub ↗

* Generates fallback output for the provided error condition. * @param {Error} error the error * @param {NormalModule} module module for which the code should be generated * @param {GenerateContext} generateContext context for generate * @returns {Source | null} generated code

(error, module, generateContext)

Source from the content-addressed store, hash-verified

596 * @returns {Source | null} generated code
597 */
598 generateError(error, module, generateContext) {
599 switch (generateContext.type) {
600 case JAVASCRIPT_TYPE: {
601 return new RawSource(
602 `throw new Error(${JSON.stringify(error.message)});`
603 );
604 }
605 case CSS_TYPE: {
606 return new RawSource(`/**\n ${error.message} \n**/`);
607 }
608 default:
609 return null;
610 }
611 }
612
613 /**
614 * Returns the source types available for this module.

Callers 2

codeGenerationMethod · 0.45
generateErrorFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected