lightning_encoding/error.rs
1// Network encoding for lightning network peer protocol data types
2// Written in 2020-2022 by
3// Dr. Maxim Orlovsky <orlovsky@pandoracore.com>
4//
5// To the extent possible under law, the author(s) have dedicated all
6// copyright and related and neighboring rights to this software to
7// the public domain worldwide. This software is distributed without
8// any warranty.
9//
10// You should have received a copy of the MIT License
11// along with this software.
12// If not, see <https://opensource.org/licenses/MIT>.
13
14use amplify::IoError;
15use strict_encoding::TlvError;
16
17#[derive(Clone, PartialEq, Eq, Hash, Debug, Display, Error, From)]
18#[display(doc_comments)]
19pub enum Error {
20 /// I/O error
21 #[from(std::io::Error)]
22 #[from(std::io::ErrorKind)]
23 #[display(inner)]
24 Io(IoError),
25
26 /// decoded BigSize is not canonical
27 BigSizeNotCanonical,
28
29 /// unexpected EOF while decoding BigSize value
30 BigSizeEof,
31
32 /// Indicates absence of BigSize value. Used in TLV stream reading
33 #[display("unexpected EOF while decoding BigSize value")]
34 BigSizeNoValue,
35
36 /// not all provided data were consumed during decoding process
37 DataNotEntirelyConsumed,
38
39 /// Custom type-specific error
40 #[display(inner)]
41 DataIntegrityError(String),
42
43 /// TLV encoding error
44 #[from]
45 #[display(inner)]
46 Tlv(TlvError),
47
48 /// unsupported value `{0}` for enum `{0}` encountered during decode
49 /// operation
50 EnumValueNotKnown(&'static str, usize),
51
52 /// data size {0} exceeds maximum allowed for the lightning message
53 TooLargeData(usize),
54}