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 {
1515 try {
1616 var json = JSON . stringify ( object )
1717 } catch ( err ) {
18- throw new SerializationError ( err . message )
18+ throw new SerializationError ( err . message , object )
1919 }
2020 return json
2121 }
@@ -25,7 +25,7 @@ class Serializer {
2525 try {
2626 var object = sjson . parse ( json )
2727 } catch ( err ) {
28- throw new DeserializationError ( err . message )
28+ throw new DeserializationError ( err . message , json )
2929 }
3030 return object
3131 }
Original file line number Diff line number Diff line change @@ -33,13 +33,15 @@ export declare class NoLivingConnectionsError extends ElasticsearchClientError {
3333export declare class SerializationError extends ElasticsearchClientError {
3434 name : string ;
3535 message : string ;
36- constructor ( message : string ) ;
36+ data : object ;
37+ constructor ( message : string , data : object ) ;
3738}
3839
3940export declare class DeserializationError extends ElasticsearchClientError {
4041 name : string ;
4142 message : string ;
42- constructor ( message : string ) ;
43+ data : string ;
44+ constructor ( message : string , data : string ) ;
4345}
4446
4547export declare class ConfigurationError extends ElasticsearchClientError {
Original file line number Diff line number Diff line change @@ -42,20 +42,22 @@ class NoLivingConnectionsError extends ElasticsearchClientError {
4242}
4343
4444class SerializationError extends ElasticsearchClientError {
45- constructor ( message ) {
46- super ( message )
45+ constructor ( message , data ) {
46+ super ( message , data )
4747 Error . captureStackTrace ( this , SerializationError )
4848 this . name = 'SerializationError'
4949 this . message = message || 'Serialization Error'
50+ this . data = data
5051 }
5152}
5253
5354class DeserializationError extends ElasticsearchClientError {
54- constructor ( message ) {
55- super ( message )
55+ constructor ( message , data ) {
56+ super ( message , data )
5657 Error . captureStackTrace ( this , DeserializationError )
5758 this . name = 'DeserializationError'
5859 this . message = message || 'Deserialization Error'
60+ this . data = data
5961 }
6062}
6163
Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ test('SerializationError', t => {
4444 t . true ( err instanceof Error )
4545 t . true ( err instanceof errors . ElasticsearchClientError )
4646 t . false ( err . hasOwnProperty ( 'meta' ) )
47+ t . true ( err . hasOwnProperty ( 'data' ) )
4748 t . end ( )
4849} )
4950
@@ -52,6 +53,7 @@ test('DeserializationError', t => {
5253 t . true ( err instanceof Error )
5354 t . true ( err instanceof errors . ElasticsearchClientError )
5455 t . false ( err . hasOwnProperty ( 'meta' ) )
56+ t . true ( err . hasOwnProperty ( 'data' ) )
5557 t . end ( )
5658} )
5759
You can’t perform that action at this time.
0 commit comments