dash_platform_queries/
error.rs1use dpp::consensus::ConsensusError;
4use dpp::validation::SimpleConsensusValidationResult;
5use dpp::ProtocolError;
6
7#[allow(clippy::large_enum_variant)]
13#[derive(Debug, thiserror::Error)]
14pub enum Error {
15 #[error("SDK misconfigured: {0}")]
17 Config(String),
18 #[error("Drive error: {0}")]
20 Drive(#[from] drive::error::Error),
21 #[error("Protocol error: {0}")]
23 Protocol(#[from] ProtocolError),
24}
25
26impl From<ConsensusError> for Error {
27 fn from(value: ConsensusError) -> Self {
28 Self::Protocol(ProtocolError::ConsensusError(Box::new(value)))
29 }
30}
31
32impl From<SimpleConsensusValidationResult> for Error {
33 fn from(value: SimpleConsensusValidationResult) -> Self {
34 value
35 .errors
36 .into_iter()
37 .next()
38 .map(Error::from)
39 .unwrap_or_else(|| {
40 Error::Protocol(ProtocolError::CorruptedCodeExecution(
41 "state transition structure validation failed without an error".to_string(),
42 ))
43 })
44 }
45}