File tree Expand file tree Collapse file tree
test/cases/compile/error-hide-stack Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ /*
2+ MIT License http://www.opensource.org/licenses/mit-license.php
3+ */
4+ "use strict" ;
5+
6+ const WebpackError = require ( "./WebpackError" ) ;
7+
8+ module . exports = class HarmonyLinkingError extends WebpackError {
9+ /** @param {string } message Error message */
10+ constructor ( message ) {
11+ super ( ) ;
12+ this . name = "HarmonyLinkingError" ;
13+ this . message = message ;
14+ this . hideStack = true ;
15+
16+ Error . captureStackTrace ( this , this . constructor ) ;
17+ }
18+ } ;
Original file line number Diff line number Diff line change 77const DependencyReference = require ( "./DependencyReference" ) ;
88const HarmonyImportDependency = require ( "./HarmonyImportDependency" ) ;
99const Template = require ( "../Template" ) ;
10+ const HarmonyLinkingError = require ( "../HarmonyLinkingError" ) ;
1011
1112class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
1213 constructor (
@@ -334,11 +335,11 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
334335 const exportName = this . id
335336 ? `the named export '${ this . id } '`
336337 : "the namespace object" ;
337- const err = new Error (
338- `Can't reexport ${ exportName } from non EcmaScript module (only default export is available)`
339- ) ;
340- err . hideStack = true ;
341- return [ err ] ;
338+ return [
339+ new HarmonyLinkingError (
340+ `Can't reexport ${ exportName } from non EcmaScript module (only default export is available)`
341+ )
342+ ] ;
342343 }
343344 return ;
344345 }
@@ -358,9 +359,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
358359 const errorMessage = `"export '${
359360 this . id
360361 } '${ idIsNotNameMessage } was not found in '${ this . userRequest } '`;
361- const err = new Error ( errorMessage ) ;
362- err . hideStack = true ;
363- return [ err ] ;
362+ return [ new HarmonyLinkingError ( errorMessage ) ] ;
364363 }
365364
366365 updateHash ( hash ) {
Original file line number Diff line number Diff line change 66
77const DependencyReference = require ( "./DependencyReference" ) ;
88const HarmonyImportDependency = require ( "./HarmonyImportDependency" ) ;
9+ const HarmonyLinkingError = require ( "../HarmonyLinkingError" ) ;
910
1011class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
1112 constructor (
@@ -78,11 +79,11 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
7879 const exportName = this . id
7980 ? `the named export '${ this . id } '`
8081 : "the namespace object" ;
81- const err = new Error (
82- `Can't import ${ exportName } from non EcmaScript module (only default export is available)`
83- ) ;
84- err . hideStack = true ;
85- return [ err ] ;
82+ return [
83+ new HarmonyLinkingError (
84+ `Can't import ${ exportName } from non EcmaScript module (only default export is available)`
85+ )
86+ ] ;
8687 }
8788 return ;
8889 }
@@ -102,9 +103,7 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
102103 const errorMessage = `"export '${
103104 this . id
104105 } '${ idIsNotNameMessage } was not found in '${ this . userRequest } '`;
105- const err = new Error ( errorMessage ) ;
106- err . hideStack = true ;
107- return [ err ] ;
106+ return [ new HarmonyLinkingError ( errorMessage ) ] ;
108107 }
109108
110109 // implement this method to allow the occurrence order plugin to count correctly
Original file line number Diff line number Diff line change @@ -3,4 +3,4 @@ module.exports = function() {
33 err . stack = "Stack" ;
44 err . hideStack = true ;
55 throw err ;
6- } ;
6+ } ;
You can’t perform that action at this time.
0 commit comments