Commit a573b58 1 parent e0ef289 commit a573b58 Copy full SHA for a573b58
File tree 1 file changed +15
-15
lines changed
1 file changed +15
-15
lines changed Original file line number Diff line number Diff line change @@ -285,40 +285,40 @@ async function verifyContent (cid, carBytes) {
285
285
}
286
286
287
287
function mapErrorToStatusCode ( err ) {
288
- // 90x codes for multiaddr parsing errors
288
+ // 7xx codes for multiaddr parsing errors
289
289
switch ( err . code ) {
290
+ case 'UNSUPPORTED_MULTIADDR_HOST_TYPE' :
291
+ return 701
290
292
case 'UNSUPPORTED_MULTIADDR_PROTO' :
291
- return 901
293
+ return 702
292
294
case 'UNSUPPORTED_MULTIADDR_SCHEME' :
293
- return 902
295
+ return 703
294
296
case 'MULTIADDR_HAS_TOO_MANY_PARTS' :
295
- return 903
296
- case 'UNSUPPORTED_MULTIADDR_HOST_TYPE' :
297
- return 904
297
+ return 704
298
298
}
299
299
300
- // 92x for content verification errors
300
+ // 9xx for content verification errors
301
301
if ( err instanceof UnsupportedHashError ) {
302
- return 921
302
+ return 901
303
303
} else if ( err instanceof HashMismatchError ) {
304
- return 922
304
+ return 902
305
305
} else if ( err . code === 'UNEXPECTED_CAR_BLOCK' ) {
306
- return 923
306
+ return 903
307
307
} else if ( err . code === 'CANNOT_PARSE_CAR_BYTES' ) {
308
- return 924
308
+ return 904
309
309
}
310
310
311
- // 91x errors for network connection errors
311
+ // 8xx errors for network connection errors
312
312
// Unfortunately, the Fetch API does not support programmatic detection of various error
313
313
// conditions. We have to check the error message text.
314
314
if ( err . message . includes ( 'dns error' ) ) {
315
- return 911
315
+ return 801
316
316
} else if ( err . message . includes ( 'tcp connect error' ) ) {
317
- return 912
317
+ return 802
318
318
}
319
319
320
320
// Fallback code for unknown errors
321
- return 900
321
+ return 600
322
322
}
323
323
324
324
async function assertOkResponse ( res , errorMsg ) {
You can’t perform that action at this time.
0 commit comments