-module(glepack@error). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -export([to_string/1]). -export_type([decode_error/0]). -if(?OTP_RELEASE >= 27). -define(MODULEDOC(Str), -moduledoc(Str)). -define(DOC(Str), -doc(Str)). -else. -define(MODULEDOC(Str), -compile([])). -define(DOC(Str), -compile([])). -endif. ?MODULEDOC(" This module contains the error types used in MessagePack encoding and decoding\n"). -type decode_error() :: invalid_format | incomplete_data | integer_too_large | invalid_utf8 | reserved_format | unknown_format | {unsupported_extension, integer()}. -file("src/glepack/error.gleam", 50). ?DOC(" Converts a DecodeError to a human-readable string\n"). -spec to_string(decode_error()) -> binary(). to_string(Error) -> case Error of invalid_format -> <<"Invalid MessagePack format"/utf8>>; incomplete_data -> <<"Incomplete MessagePack data, more bytes needed"/utf8>>; integer_too_large -> <<"Integer too large for Gleam's Int type"/utf8>>; invalid_utf8 -> <<"Invalid UTF-8 string data"/utf8>>; reserved_format -> <<"Reserved MessagePack format (0xc1) encountered"/utf8>>; unknown_format -> <<"Unknown MessagePack format encountered"/utf8>>; {unsupported_extension, Type_id} -> <<"Unsupported extension type: "/utf8, (erlang:integer_to_binary(Type_id))/binary>> end.