esvm_rlp/
error.rs

1// Copyright 2015-2017 Parity Technologies
2//
3// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
6// option. This file may not be copied, modified, or distributed
7// except according to those terms.
8
9use std::fmt;
10use std::error::Error as StdError;
11
12#[derive(Debug, PartialEq, Eq)]
13/// Error concerning the RLP decoder.
14pub enum DecoderError {
15	/// Data has additional bytes at the end of the valid RLP fragment.
16	RlpIsTooBig,
17	/// Data has too few bytes for valid RLP.
18	RlpIsTooShort,
19	/// Expect an encoded list, RLP was something else.
20	RlpExpectedToBeList,
21	/// Expect encoded data, RLP was something else.
22	RlpExpectedToBeData,
23	/// Expected a different size list.
24	RlpIncorrectListLen,
25	/// Data length number has a prefixed zero byte, invalid for numbers.
26	RlpDataLenWithZeroPrefix,
27	/// List length number has a prefixed zero byte, invalid for numbers.
28	RlpListLenWithZeroPrefix,
29	/// Non-canonical (longer than necessary) representation used for data or list.
30	RlpInvalidIndirection,
31	/// Declared length is inconsistent with data specified after.
32	RlpInconsistentLengthAndData,
33	/// Custom rlp decoding error.
34	Custom(&'static str),
35}
36
37impl StdError for DecoderError {
38	fn description(&self) -> &str {
39		"builder error"
40	}
41}
42
43impl fmt::Display for DecoderError {
44	fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
45		fmt::Debug::fmt(&self, f)
46	}
47}