ckb_fixed_hash_core/
error.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
//! Conversion errors.

use thiserror::Error;

/// The associated error of [`FromStr`] which can be returned from parsing a string.
///
/// [`FromStr`]: https://doc.rust-lang.org/std/str/trait.FromStr.html#associatedtype.Err
#[derive(Error, Debug, PartialEq, Eq)]
pub enum FromStrError {
    /// Invalid character.
    #[error("Invalid character code `{chr}` at {idx}")]
    InvalidCharacter {
        /// The value of the invalid character.
        chr: u8,
        /// The index of the invalid character.
        idx: usize,
    },
    /// Invalid length.
    #[error("Invalid length: {0}")]
    InvalidLength(usize),
}

/// The error which can be returned when convert a byte slice back into a Hash.
#[derive(Error, Debug, PartialEq, Eq)]
pub enum FromSliceError {
    /// Invalid length.
    #[error("Invalid length: {0}")]
    InvalidLength(usize),
}