#[cfg(feature = "nns-host")]
use crate::HostCacheError;
use crate::nns::governance::NnsGovernanceError;
#[cfg(feature = "nns-host")]
use std::path::PathBuf;
use thiserror::Error as ThisError;
#[derive(Debug, ThisError)]
pub enum NnsNeuronError {
#[error(transparent)]
Governance(#[from] NnsGovernanceError),
#[error("invalid NNS neuron page size {page_size}; expected 1..={max_page_size}")]
InvalidPageSize {
page_size: u32,
max_page_size: u32,
},
#[error("NNS Governance rejected the neuron query with code {error_type}: {message}")]
GovernanceResponse {
error_type: i32,
message: String,
},
#[error("NNS neuron {neuron_id} was not found")]
NeuronNotFound {
neuron_id: u64,
},
#[error("NNS Governance returned a neuron row without an id")]
MissingNeuronId,
#[error("invalid NNS neuron response: {reason}")]
InvalidResponse {
reason: String,
},
}
#[cfg(feature = "nns-host")]
#[derive(Debug, ThisError)]
pub enum NnsNeuronHostError {
#[error("NNS neurons cache is missing at {}", path.display())]
MissingNeuronCache {
path: PathBuf,
},
#[error(transparent)]
Distribution(#[from] super::NnsNeuronDistributionError),
#[error(transparent)]
Neuron(#[from] NnsNeuronError),
#[error("invalid NNS neuron cache at {}: {reason}", path.display())]
InvalidCache {
path: PathBuf,
reason: String,
},
#[error(transparent)]
Cache(#[from] HostCacheError),
}