66
77const createHash = require ( "./util/createHash" ) ;
88
9- const hash = Symbol ( ) ;
10- const meta = Symbol ( ) ;
9+ const hash = Symbol ( "hash" ) ;
10+ const meta = Symbol ( "meta" ) ;
1111
1212module . exports = class WebpackError extends Error {
1313 constructor (
1414 message ,
15- line = 0 ,
16- column = 0 ,
17- columnEnd = 0 ,
18- category = "error"
15+ options = Object . create ( {
16+ category : "error" ,
17+ // NOTE: went with a more semantic structure here, even though it
18+ // deviates from other similar structures in webpack
19+ column : { end : 0 , start : 0 } ,
20+ line : { end : 0 , start : 0 }
21+ } )
1922 ) {
2023 // TODO: enable message assertion during construction in a commit to follow
2124 // if (!message) {
@@ -29,11 +32,10 @@ module.exports = class WebpackError extends Error {
2932 super ( message ) ;
3033
3134 this [ hash ] = createHash ( "md4" ) ;
32- this [ meta ] = { } ;
33- this . category = category ;
34- this . column = column ;
35- this . columnEnd = columnEnd ;
36- this . line = line ;
35+ this [ meta ] = Object . create ( null ) ;
36+ this . category = options . category ;
37+ this . column = options . column ;
38+ this . line = options . line ;
3739
3840 // TODO: enable abstract protection at a commit to follow
3941 // if (this.constructor === WebpackError) {
@@ -51,7 +53,7 @@ module.exports = class WebpackError extends Error {
5153 // use process.stdout to assert the message will be displayed in
5254 // environments where console has been proxied. this mimics node's
5355 // util.deprecate method.
54- process . stdout . write ( `DeprecationWarning: ${ message } \n${ stack } \n` ) ;
56+ process . emitWarning ( `DeprecationWarning: ${ message } \n${ stack } \n` ) ;
5557 }
5658
5759 get id ( ) {
0 commit comments