dpp/errors/consensus/basic/
invalid_identifier_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("Invalid {identifier_name}: {message}")]
12#[platform_serialize(unversioned)]
13pub struct InvalidIdentifierError {
14    /*
15
16    DO NOT CHANGE ORDER OF FIELDS WITHOUT INTRODUCING OF NEW VERSION
17
18    */
19    identifier_name: String,
20    message: String,
21}
22
23impl InvalidIdentifierError {
24    pub fn new(identifier_name: String, message: String) -> Self {
25        Self {
26            identifier_name,
27            message,
28        }
29    }
30
31    pub fn identifier_name(&self) -> &str {
32        &self.identifier_name
33    }
34
35    pub fn message(&self) -> &str {
36        &self.message
37    }
38}
39
40impl From<InvalidIdentifierError> for ConsensusError {
41    fn from(err: InvalidIdentifierError) -> Self {
42        Self::BasicError(BasicError::InvalidIdentifierError(err))
43    }
44}