dup_crypto/mnemonic/error.rs
1// Copyright (C) 2020 Eloïs SANCHEZ.
2//
3// This program is free software: you can redistribute it and/or modify
4// it under the terms of the GNU Affero General Public License as
5// published by the Free Software Foundation, either version 3 of the
6// License, or (at your option) any later version.
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU Affero General Public License for more details.
12//
13// You should have received a copy of the GNU Affero General Public License
14// along with this program. If not, see <https://www.gnu.org/licenses/>.
15
16use super::mnemonic_type::MnemonicType;
17use crate::rand::UnspecifiedRandError;
18use thiserror::Error;
19
20#[derive(Clone, Copy, Debug, Error)]
21/// Mnemonic error
22pub enum MnemonicError {
23 /// invalid checksum
24 #[error("invalid checksum")]
25 InvalidChecksum,
26 /// invalid word in phrase
27 #[error("invalid word in phrase")]
28 InvalidWord,
29 /// invalid keysize
30 #[error("invalid keysize: {0}")]
31 InvalidKeysize(usize),
32 /// invalid number of words in phrase
33 #[error("invalid number of words in phrase: {0}")]
34 InvalidWordLength(usize),
35 /// invalid entropy length
36 #[error("invalid entropy length {0} bits for mnemonic type {1:?}")]
37 InvalidEntropyLength(usize, MnemonicType),
38 /// Unknown language
39 #[error("Unknown language")]
40 UnknownLanguage,
41 /// Unspecified rand error
42 #[error("Unspecified rand error")]
43 UnspecifiedRandError(UnspecifiedRandError),
44}