dpp/errors/consensus/basic/
overflow_error.rs

1use crate::consensus::basic::BasicError;
2use crate::consensus::ConsensusError;
3use crate::errors::ProtocolError;
4use bincode::{Decode, Encode};
5use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize};
6use thiserror::Error;
7
8#[derive(
9    Error, Debug, Clone, PartialEq, Eq, Encode, Decode, PlatformSerialize, PlatformDeserialize,
10)]
11#[error("Overflow error")]
12#[platform_serialize(unversioned)]
13pub struct OverflowError {
14    /*
15
16    DO NOT CHANGE ORDER OF FIELDS WITHOUT INTRODUCING OF NEW VERSION
17
18    */
19    message: String,
20}
21
22impl OverflowError {
23    pub fn new(message: String) -> Self {
24        Self { message }
25    }
26
27    pub fn message(&self) -> &str {
28        self.message.as_str()
29    }
30}
31impl From<OverflowError> for ConsensusError {
32    fn from(err: OverflowError) -> Self {
33        Self::BasicError(BasicError::OverflowError(err))
34    }
35}