Skip to main content

codec_multibase/
error.rs

1// SPDX-FileCopyrightText: 2026 ReallyMe LLC
2//
3// SPDX-License-Identifier: MIT OR Apache-2.0
4
5use thiserror::Error;
6
7use crate::base58btc::Base58Error;
8
9/// Error returned when decoding a multibase string fails.
10#[derive(Debug, Error)]
11#[non_exhaustive]
12pub enum MultibaseError {
13    /// Encoded multibase text exceeded the supported resource limit.
14    #[error("multibase input too large")]
15    InputTooLarge,
16    /// The input is too short to contain a multibase prefix and payload.
17    #[error("invalid multibase string: too short")]
18    TooShort,
19
20    // Deliberately carries no payload: the rejected prefix comes from
21    // untrusted input, and error variants must not echo it back.
22    /// The leading multibase prefix denotes an unsupported base encoding.
23    #[error("unsupported multibase prefix")]
24    UnsupportedPrefix,
25
26    /// The base58btc payload failed to decode.
27    #[error(transparent)]
28    Base58(#[from] Base58Error),
29
30    /// The base64url payload failed to decode.
31    #[error("invalid base64url")]
32    Base64Url,
33
34    /// The encoded output length would exceed the supported allocation domain.
35    #[error("multibase encoded length overflow")]
36    LengthOverflow,
37}