File tree Expand file tree Collapse file tree 4 files changed +14
-8
lines changed Expand file tree Collapse file tree 4 files changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ class Serializer {
15
15
try {
16
16
var json = JSON . stringify ( object )
17
17
} catch ( err ) {
18
- throw new SerializationError ( err . message )
18
+ throw new SerializationError ( err . message , object )
19
19
}
20
20
return json
21
21
}
@@ -25,7 +25,7 @@ class Serializer {
25
25
try {
26
26
var object = sjson . parse ( json )
27
27
} catch ( err ) {
28
- throw new DeserializationError ( err . message )
28
+ throw new DeserializationError ( err . message , json )
29
29
}
30
30
return object
31
31
}
Original file line number Diff line number Diff line change @@ -33,13 +33,15 @@ export declare class NoLivingConnectionsError extends ElasticsearchClientError {
33
33
export declare class SerializationError extends ElasticsearchClientError {
34
34
name : string ;
35
35
message : string ;
36
- constructor ( message : string ) ;
36
+ data : object ;
37
+ constructor ( message : string , data : object ) ;
37
38
}
38
39
39
40
export declare class DeserializationError extends ElasticsearchClientError {
40
41
name : string ;
41
42
message : string ;
42
- constructor ( message : string ) ;
43
+ data : string ;
44
+ constructor ( message : string , data : string ) ;
43
45
}
44
46
45
47
export declare class ConfigurationError extends ElasticsearchClientError {
Original file line number Diff line number Diff line change @@ -42,20 +42,22 @@ class NoLivingConnectionsError extends ElasticsearchClientError {
42
42
}
43
43
44
44
class SerializationError extends ElasticsearchClientError {
45
- constructor ( message ) {
46
- super ( message )
45
+ constructor ( message , data ) {
46
+ super ( message , data )
47
47
Error . captureStackTrace ( this , SerializationError )
48
48
this . name = 'SerializationError'
49
49
this . message = message || 'Serialization Error'
50
+ this . data = data
50
51
}
51
52
}
52
53
53
54
class DeserializationError extends ElasticsearchClientError {
54
- constructor ( message ) {
55
- super ( message )
55
+ constructor ( message , data ) {
56
+ super ( message , data )
56
57
Error . captureStackTrace ( this , DeserializationError )
57
58
this . name = 'DeserializationError'
58
59
this . message = message || 'Deserialization Error'
60
+ this . data = data
59
61
}
60
62
}
61
63
Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ test('SerializationError', t => {
44
44
t . true ( err instanceof Error )
45
45
t . true ( err instanceof errors . ElasticsearchClientError )
46
46
t . false ( err . hasOwnProperty ( 'meta' ) )
47
+ t . true ( err . hasOwnProperty ( 'data' ) )
47
48
t . end ( )
48
49
} )
49
50
@@ -52,6 +53,7 @@ test('DeserializationError', t => {
52
53
t . true ( err instanceof Error )
53
54
t . true ( err instanceof errors . ElasticsearchClientError )
54
55
t . false ( err . hasOwnProperty ( 'meta' ) )
56
+ t . true ( err . hasOwnProperty ( 'data' ) )
55
57
t . end ( )
56
58
} )
57
59
You can’t perform that action at this time.
0 commit comments