Skip to main content

codec_multibase/
error.rs

1// SPDX-FileCopyrightText: Copyright © 2026 ReallyMe LLC. All rights reserved
2//
3// SPDX-License-Identifier: 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)]
11pub enum MultibaseError {
12    /// The input is too short to contain a multibase prefix and payload.
13    #[error("invalid multibase string: too short")]
14    TooShort,
15
16    // Deliberately carries no payload: the rejected prefix comes from
17    // untrusted input, and error variants must not echo it back.
18    /// The leading multibase prefix denotes an unsupported base encoding.
19    #[error("unsupported multibase prefix")]
20    UnsupportedPrefix,
21
22    /// The base58btc payload failed to decode.
23    #[error(transparent)]
24    Base58(#[from] Base58Error),
25
26    /// The base64url payload failed to decode.
27    #[error("invalid base64url")]
28    Base64Url,
29}