@@ -21,6 +21,7 @@ import {debug} from "./log";
21
21
import { alloc } from "./buf" ;
22
22
import utf8 from "./utf8" ;
23
23
import { Integer , int } from "../integer" ;
24
+ import { newError } from './../error' ;
24
25
25
26
let MAX_CHUNK_SIZE = 16383 ,
26
27
TINY_STRING = 0x80 ,
@@ -108,7 +109,7 @@ class Packer {
108
109
this . pack ( x [ key ] ) ;
109
110
}
110
111
} else {
111
- throw new Error ( "Cannot pack this value: " + x ) ;
112
+ throw newError ( "Cannot pack this value: " + x ) ;
112
113
}
113
114
}
114
115
@@ -174,7 +175,7 @@ class Packer {
174
175
this . _ch . writeUInt8 ( size % 256 ) ;
175
176
this . _ch . writeBytes ( bytes ) ;
176
177
} else {
177
- throw new ProtocolError ( "UTF-8 strings of size " + size + " are not supported" ) ;
178
+ throw newError ( "UTF-8 strings of size " + size + " are not supported" ) ;
178
179
}
179
180
}
180
181
@@ -195,7 +196,7 @@ class Packer {
195
196
this . _ch . writeUInt8 ( ( size / 256 >> 0 ) % 256 ) ;
196
197
this . _ch . writeUInt8 ( size % 256 ) ;
197
198
} else {
198
- throw new ProtocolError ( "Lists of size " + size + " are not supported" ) ;
199
+ throw newError ( "Lists of size " + size + " are not supported" ) ;
199
200
}
200
201
}
201
202
@@ -216,7 +217,7 @@ class Packer {
216
217
this . _ch . writeUInt8 ( ( size / 256 >> 0 ) % 256 ) ;
217
218
this . _ch . writeUInt8 ( size % 256 ) ;
218
219
} else {
219
- throw new ProtocolError ( "Maps of size " + size + " are not supported" ) ;
220
+ throw newError ( "Maps of size " + size + " are not supported" ) ;
220
221
}
221
222
}
222
223
@@ -233,7 +234,7 @@ class Packer {
233
234
this . _ch . writeUInt8 ( size / 256 >> 0 ) ;
234
235
this . _ch . writeUInt8 ( size % 256 ) ;
235
236
} else {
236
- throw new ProtocolError ( "Structures of size " + size + " are not supported" ) ;
237
+ throw newError ( "Structures of size " + size + " are not supported" ) ;
237
238
}
238
239
}
239
240
}
@@ -340,13 +341,13 @@ class Unpacker {
340
341
} else if ( markerHigh == 0xB0 ) {
341
342
return this . unpackStruct ( markerLow , buffer ) ;
342
343
} else {
343
- throw new ProtocolError ( "Unknown packed value with marker " + marker . toString ( 16 ) ) ;
344
+ throw newError ( "Unknown packed value with marker " + marker . toString ( 16 ) ) ;
344
345
}
345
346
}
346
347
}
347
348
348
349
export default {
349
350
Packer,
350
351
Unpacker,
351
- Structure,
352
+ Structure
352
353
} ;
0 commit comments