glepack/error

This module contains the error types used in MessagePack encoding and decoding

Types

Errors that can occur when decoding MessagePack data.

This type provides specific error cases to help with debugging and proper error handling when working with MessagePack data.

Example Usage

import glepack/decode
import glepack/error

pub fn handle_decode(data: BitArray) {
  case decode.value(data) {
    Ok(value) -> // Handle success case
    Error(error.IncompleteData)
    Error(error.InvalidUtf8)
    Error(error.IntegerTooLarge)
    Error(_) -> // Handle other errors
  }
}
pub type DecodeError {
  InvalidFormat
  IncompleteData
  IntegerTooLarge
  InvalidUtf8
  ReservedFormat
  UnknownFormat
  UnsupportedExtension(type_id: Int)
}

Constructors

  • InvalidFormat

    The input data is not valid MessagePack

  • IncompleteData

    The input data is incomplete and more bytes are needed

  • IntegerTooLarge

    The input contains an integer that is too large for Gleam’s Int type

  • InvalidUtf8

    The input contains a string that is not valid UTF-8

  • ReservedFormat

    The input contains a reserved format (0xc1)

  • UnknownFormat

    An unknown format was encountered

  • UnsupportedExtension(type_id: Int)

    An extension type that is not supported by the decoder

Functions

pub fn to_string(error: DecodeError) -> String

Converts a DecodeError to a human-readable string

Search Document