Skip to content

Commit a573b58

Browse files
committed
fixup! change synthetic status codes
Signed-off-by: Miroslav Bajtoš <oss@bajtos.net>
1 parent e0ef289 commit a573b58

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

lib/spark.js

+15-15
Original file line numberDiff line numberDiff line change
@@ -285,40 +285,40 @@ async function verifyContent (cid, carBytes) {
285285
}
286286

287287
function mapErrorToStatusCode (err) {
288-
// 90x codes for multiaddr parsing errors
288+
// 7xx codes for multiaddr parsing errors
289289
switch (err.code) {
290+
case 'UNSUPPORTED_MULTIADDR_HOST_TYPE':
291+
return 701
290292
case 'UNSUPPORTED_MULTIADDR_PROTO':
291-
return 901
293+
return 702
292294
case 'UNSUPPORTED_MULTIADDR_SCHEME':
293-
return 902
295+
return 703
294296
case 'MULTIADDR_HAS_TOO_MANY_PARTS':
295-
return 903
296-
case 'UNSUPPORTED_MULTIADDR_HOST_TYPE':
297-
return 904
297+
return 704
298298
}
299299

300-
// 92x for content verification errors
300+
// 9xx for content verification errors
301301
if (err instanceof UnsupportedHashError) {
302-
return 921
302+
return 901
303303
} else if (err instanceof HashMismatchError) {
304-
return 922
304+
return 902
305305
} else if (err.code === 'UNEXPECTED_CAR_BLOCK') {
306-
return 923
306+
return 903
307307
} else if (err.code === 'CANNOT_PARSE_CAR_BYTES') {
308-
return 924
308+
return 904
309309
}
310310

311-
// 91x errors for network connection errors
311+
// 8xx errors for network connection errors
312312
// Unfortunately, the Fetch API does not support programmatic detection of various error
313313
// conditions. We have to check the error message text.
314314
if (err.message.includes('dns error')) {
315-
return 911
315+
return 801
316316
} else if (err.message.includes('tcp connect error')) {
317-
return 912
317+
return 802
318318
}
319319

320320
// Fallback code for unknown errors
321-
return 900
321+
return 600
322322
}
323323

324324
async function assertOkResponse (res, errorMsg) {

0 commit comments

Comments
 (0)