Skip to content

Commit d5d1ee9

Browse files
committed
refactor: standardize error messages
1 parent d62d015 commit d5d1ee9

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/utils/car-block-getter.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,19 @@ export class CarBlockGetter {
3434
const { value, done } = await promiseTimeout(
3535
this.carItr.next(),
3636
this.getBlockTimeout,
37-
new TimeoutError(`get block ${cid} timed out`)
37+
new TimeoutError(`get ${cid}: timed out`)
3838
)
3939

4040
if (!value && done) {
41-
throw new VerificationError('CAR file has no more blocks.')
41+
throw new VerificationError(`get ${cid}: CAR file has no more blocks`)
4242
}
4343

4444
const { cid: blockCid, bytes } = value
4545
await verifyBlock(blockCid, bytes)
4646

4747
if (!cid.equals(blockCid)) {
4848
throw new VerificationError(
49-
`received block with cid ${blockCid}, expected ${cid}`
49+
`get ${cid}: received ${blockCid} instead`
5050
)
5151
}
5252

test/car.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ describe('CAR Verification', () => {
115115
},
116116
{
117117
name: 'VerificationError',
118-
message: 'CAR file has no more blocks.'
118+
message: 'get bafybeidhkumeonuwkebh2i4fc7o7lguehauradvlk57gzake6ggjsy372a: CAR file has no more blocks'
119119
}
120120
)
121121
})
@@ -155,7 +155,7 @@ describe('CAR Verification', () => {
155155
{
156156
name: 'VerificationError',
157157
message:
158-
'received block with cid bafybeidhkumeonuwkebh2i4fc7o7lguehauradvlk57gzake6ggjsy372a, expected bafybeigeqgfwhivuuxgmuvcrrwvs4j3yfzgljssvnuqzokm6uby4fpmwsa'
158+
'get bafybeigeqgfwhivuuxgmuvcrrwvs4j3yfzgljssvnuqzokm6uby4fpmwsa: received bafybeidhkumeonuwkebh2i4fc7o7lguehauradvlk57gzake6ggjsy372a instead'
159159
}
160160
)
161161
})

0 commit comments

Comments
 (0)