Skip to content

Bytes Errors

Bytes.InvalidBytesBooleanError

Thrown when the bytes value cannot be represented as a boolean.

Examples

import { Bytes } from 'ox'
 
Bytes.toBoolean(Bytes.from([5]))
Bytes.InvalidBytesBooleanError: Bytes value `[5]` is not a valid boolean.
The bytes array must contain a single byte of either a `0` or `1` value.

Source: src/Bytes.ts

Bytes.InvalidBytesTypeError

Thrown when a value cannot be converted to bytes.

Examples

import { Bytes } from 'ox'
 
Bytes.from('foo')
Bytes.InvalidBytesTypeError: Value `foo` of type `string` is an invalid Bytes value.

Source: src/Bytes.ts

Bytes.SizeExceedsPaddingSizeError

Thrown when a the padding size exceeds the maximum allowed size.

Examples

import { Bytes } from 'ox'
 
Bytes.padLeft(Bytes.fromString('Hello World!'), 8)
[Bytes.SizeExceedsPaddingSizeError: Bytes size (`12`) exceeds padding size (`8`).

Source: src/Bytes.ts

Bytes.SizeOverflowError

Thrown when a size exceeds the maximum allowed size.

Examples

import { Bytes } from 'ox'
 
Bytes.fromString('Hello World!', { size: 8 })
Bytes.SizeOverflowError: Size cannot exceed `8` bytes. Given size: `12` bytes.

Source: src/Bytes.ts

Bytes.SliceOffsetOutOfBoundsError

Thrown when a slice offset is out-of-bounds.

Examples

import { Bytes } from 'ox'
 
Bytes.slice(Bytes.from([1, 2, 3]), 4)
Bytes.SliceOffsetOutOfBoundsError: Slice starting at offset `4` is out-of-bounds (size: `3`).

Source: src/Bytes.ts