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)]
11#[non_exhaustive]
12pub enum MultibaseError {
13 /// The input is too short to contain a multibase prefix and payload.
14 #[error("invalid multibase string: too short")]
15 TooShort,
16
17 // Deliberately carries no payload: the rejected prefix comes from
18 // untrusted input, and error variants must not echo it back.
19 /// The leading multibase prefix denotes an unsupported base encoding.
20 #[error("unsupported multibase prefix")]
21 UnsupportedPrefix,
22
23 /// The base58btc payload failed to decode.
24 #[error(transparent)]
25 Base58(#[from] Base58Error),
26
27 /// The base64url payload failed to decode.
28 #[error("invalid base64url")]
29 Base64Url,
30
31 /// The encoded output length would exceed the supported allocation domain.
32 #[error("multibase encoded length overflow")]
33 LengthOverflow,
34}