dpp/errors/consensus/basic/
overflow_error.rs1use crate::consensus::basic::BasicError;
2use crate::consensus::ConsensusError;
3use crate::errors::ProtocolError;
4use bincode::{Decode, DecodeUntrusted, Encode};
5use platform_serialization_derive::{
6 PlatformDeserializeTrusted, PlatformDeserializeUntrusted, PlatformSerialize,
7};
8use thiserror::Error;
9
10#[derive(
11 Error,
12 Debug,
13 Clone,
14 PartialEq,
15 Eq,
16 Encode,
17 Decode,
18 PlatformSerialize,
19 PlatformDeserializeTrusted,
20 PlatformDeserializeUntrusted,
21 DecodeUntrusted,
22)]
23#[error("Overflow error")]
24#[platform_serialize(unversioned)]
25pub struct OverflowError {
26 message: String,
32}
33
34impl OverflowError {
35 pub fn new(message: String) -> Self {
36 Self { message }
37 }
38
39 pub fn message(&self) -> &str {
40 self.message.as_str()
41 }
42}
43impl From<OverflowError> for ConsensusError {
44 fn from(err: OverflowError) -> Self {
45 Self::BasicError(BasicError::OverflowError(err))
46 }
47}