Skip to content

Commit 304ec71

Browse files
committed
fix: update error name
1 parent 10040cc commit 304ec71

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

packages/blockstore-core/src/identity.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import type { CID } from 'multiformats/cid'
77
// https://github.com/multiformats/multicodec/blob/d06fc6194710e8909bac64273c43f16b56ca4c34/table.csv#L2
88
const IDENTITY_CODEC = 0x00
99

10-
class IdentityDigestTooLongError extends Error {
11-
static name = 'IdentityDigestTooLongError'
12-
name = 'IdentityDigestTooLongError'
10+
class IdentityHashDigestTooLongError extends Error {
11+
static name = 'IdentityHashDigestTooLongError'
12+
name = 'IdentityHashDigestTooLongError'
1313
}
1414

1515
export interface IdentityBlockstoreInit {
@@ -30,7 +30,7 @@ export class IdentityBlockstore extends BaseBlockstore {
3030
put (key: CID, block: Uint8Array | AwaitIterable<Uint8Array>, options?: AbortOptions): Await<CID> {
3131
if (key.multihash.code === IDENTITY_CODEC) {
3232
if (this.maxDigestLength != null && key.multihash.digest.byteLength > this.maxDigestLength) {
33-
throw new IdentityDigestTooLongError(`Identity digest too long - ${key.multihash.digest.byteLength} > this.maxDigestLength`)
33+
throw new IdentityHashDigestTooLongError(`Identity digest too long - ${key.multihash.digest.byteLength} > this.maxDigestLength`)
3434
}
3535

3636
options?.signal?.throwIfAborted()
@@ -48,7 +48,7 @@ export class IdentityBlockstore extends BaseBlockstore {
4848
* get (key: CID, options?: AbortOptions): AwaitGenerator<Uint8Array> {
4949
if (key.multihash.code === IDENTITY_CODEC) {
5050
if (this.maxDigestLength != null && key.multihash.digest.byteLength > this.maxDigestLength) {
51-
throw new IdentityDigestTooLongError(`Identity digest too long - ${key.multihash.digest.byteLength} > this.maxDigestLength`)
51+
throw new IdentityHashDigestTooLongError(`Identity digest too long - ${key.multihash.digest.byteLength} > this.maxDigestLength`)
5252
}
5353

5454
options?.signal?.throwIfAborted()
@@ -67,7 +67,7 @@ export class IdentityBlockstore extends BaseBlockstore {
6767
has (key: CID, options?: AbortOptions): Await<boolean> {
6868
if (key.multihash.code === IDENTITY_CODEC) {
6969
if (this.maxDigestLength != null && key.multihash.digest.byteLength > this.maxDigestLength) {
70-
throw new IdentityDigestTooLongError(`Identity digest too long - ${key.multihash.digest.byteLength} > this.maxDigestLength`)
70+
throw new IdentityHashDigestTooLongError(`Identity digest too long - ${key.multihash.digest.byteLength} > this.maxDigestLength`)
7171
}
7272

7373
options?.signal?.throwIfAborted()
@@ -85,7 +85,7 @@ export class IdentityBlockstore extends BaseBlockstore {
8585
delete (key: CID, options?: AbortOptions): Await<void> {
8686
if (key.code === IDENTITY_CODEC) {
8787
if (this.maxDigestLength != null && key.multihash.digest.byteLength > this.maxDigestLength) {
88-
throw new IdentityDigestTooLongError(`Identity digest too long - ${key.multihash.digest.byteLength} > this.maxDigestLength`)
88+
throw new IdentityHashDigestTooLongError(`Identity digest too long - ${key.multihash.digest.byteLength} > this.maxDigestLength`)
8989
}
9090

9191
options?.signal?.throwIfAborted()

packages/blockstore-core/test/identity.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,12 @@ describe('identity', () => {
142142
expect(blockstore.has(CID.createV1(raw.code, identity.digest(ok)))).to.be.ok()
143143

144144
expect(() => all(blockstore.get(CID.createV1(raw.code, identity.digest(tooLong))))).to.throw()
145-
.with.property('name', 'IdentityDigestTooLongError')
145+
.with.property('name', 'IdentityHashDigestTooLongError')
146146

147147
expect(() => blockstore.put(CID.createV1(raw.code, identity.digest(tooLong)), buf)).to.throw()
148-
.with.property('name', 'IdentityDigestTooLongError')
148+
.with.property('name', 'IdentityHashDigestTooLongError')
149149

150150
expect(() => blockstore.has(CID.createV1(raw.code, identity.digest(tooLong)))).to.throw()
151-
.with.property('name', 'IdentityDigestTooLongError')
151+
.with.property('name', 'IdentityHashDigestTooLongError')
152152
})
153153
})

0 commit comments

Comments
 (0)