You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
1.7 KiB
67 lines
1.7 KiB
import { versionedHashVersionKzg } from '../constants/kzg.js'
|
|
import type { Hash } from '../types/misc.js'
|
|
|
|
import { BaseError } from './base.js'
|
|
|
|
export type BlobSizeTooLargeErrorType = BlobSizeTooLargeError & {
|
|
name: 'BlobSizeTooLargeError'
|
|
}
|
|
export class BlobSizeTooLargeError extends BaseError {
|
|
constructor({ maxSize, size }: { maxSize: number; size: number }) {
|
|
super('Blob size is too large.', {
|
|
metaMessages: [`Max: ${maxSize} bytes`, `Given: ${size} bytes`],
|
|
name: 'BlobSizeTooLargeError',
|
|
})
|
|
}
|
|
}
|
|
|
|
export type EmptyBlobErrorType = EmptyBlobError & {
|
|
name: 'EmptyBlobError'
|
|
}
|
|
export class EmptyBlobError extends BaseError {
|
|
constructor() {
|
|
super('Blob data must not be empty.', { name: 'EmptyBlobError' })
|
|
}
|
|
}
|
|
|
|
export type InvalidVersionedHashSizeErrorType =
|
|
InvalidVersionedHashSizeError & {
|
|
name: 'InvalidVersionedHashSizeError'
|
|
}
|
|
export class InvalidVersionedHashSizeError extends BaseError {
|
|
constructor({
|
|
hash,
|
|
size,
|
|
}: {
|
|
hash: Hash
|
|
size: number
|
|
}) {
|
|
super(`Versioned hash "${hash}" size is invalid.`, {
|
|
metaMessages: ['Expected: 32', `Received: ${size}`],
|
|
name: 'InvalidVersionedHashSizeError',
|
|
})
|
|
}
|
|
}
|
|
|
|
export type InvalidVersionedHashVersionErrorType =
|
|
InvalidVersionedHashVersionError & {
|
|
name: 'InvalidVersionedHashVersionError'
|
|
}
|
|
export class InvalidVersionedHashVersionError extends BaseError {
|
|
constructor({
|
|
hash,
|
|
version,
|
|
}: {
|
|
hash: Hash
|
|
version: number
|
|
}) {
|
|
super(`Versioned hash "${hash}" version is invalid.`, {
|
|
metaMessages: [
|
|
`Expected: ${versionedHashVersionKzg}`,
|
|
`Received: ${version}`,
|
|
],
|
|
name: 'InvalidVersionedHashVersionError',
|
|
})
|
|
}
|
|
}
|