6
6
7
7
const createHash = require ( "./util/createHash" ) ;
8
8
9
- const hash = Symbol ( ) ;
10
- const meta = Symbol ( ) ;
9
+ const hash = Symbol ( "hash" ) ;
10
+ const meta = Symbol ( "meta" ) ;
11
11
12
12
module . exports = class WebpackError extends Error {
13
13
constructor (
14
14
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
+ } )
19
22
) {
20
23
// TODO: enable message assertion during construction in a commit to follow
21
24
// if (!message) {
@@ -29,11 +32,10 @@ module.exports = class WebpackError extends Error {
29
32
super ( message ) ;
30
33
31
34
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 ;
37
39
38
40
// TODO: enable abstract protection at a commit to follow
39
41
// if (this.constructor === WebpackError) {
@@ -51,7 +53,7 @@ module.exports = class WebpackError extends Error {
51
53
// use process.stdout to assert the message will be displayed in
52
54
// environments where console has been proxied. this mimics node's
53
55
// util.deprecate method.
54
- process . stdout . write ( `DeprecationWarning: ${ message } \n${ stack } \n` ) ;
56
+ process . emitWarning ( `DeprecationWarning: ${ message } \n${ stack } \n` ) ;
55
57
}
56
58
57
59
get id ( ) {
0 commit comments