use crate::{EvalError, ExecError};
use snarkvm_circuit_environment::ConstraintUnsatisfied;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum ProcessAuthError {
#[error("Stack authorization failed: {0}")]
StackAuth(#[from] StackAuthError),
#[error(transparent)]
Anyhow(#[from] anyhow::Error),
}
#[derive(Debug, Error)]
pub enum ProcessEvalError {
#[error("Stack evaluation failed: {0}")]
StackEval(#[from] StackEvalError),
#[error(transparent)]
Anyhow(#[from] anyhow::Error),
}
#[derive(Debug, Error)]
pub enum ProcessExecError {
#[error("Stack execution failed: {0}")]
StackExec(#[from] StackExecError),
#[error(transparent)]
Anyhow(#[from] anyhow::Error),
}
#[derive(Debug, Error)]
pub enum ProcessDeployError {
#[error("Stack synthesis failed: {0}")]
StackExec(#[from] StackExecError),
#[error(transparent)]
Anyhow(#[from] anyhow::Error),
}
#[derive(Debug, Error)]
pub enum CallEvalError {
#[error("Substack evaluation failed: {0}")]
StackEval(#[from] StackEvalError),
#[error(transparent)]
Anyhow(#[from] anyhow::Error),
}
#[derive(Debug, Error)]
pub enum CallExecError {
#[error("Substack execution failed: {0}")]
StackExec(#[from] StackExecError),
#[error("Substack evaluation failed: {0}")]
StackEval(#[from] StackEvalError),
#[error(transparent)]
Constraint(#[from] ConstraintUnsatisfied),
#[error(transparent)]
Anyhow(#[from] anyhow::Error),
}
#[derive(Debug, Error)]
pub enum StackAuthError {
#[error("Stack execution failed: {0}")]
Exec(#[from] StackExecError),
#[error("Stack evaluation failed: {0}")]
Eval(#[from] StackEvalError),
#[error(transparent)]
Anyhow(#[from] anyhow::Error),
}
#[derive(Debug, Error)]
pub enum StackExecError {
#[error(transparent)]
Instruction(#[from] IndexedInstructionError<InstructionError>),
#[error(transparent)]
Constraint(#[from] ConstraintUnsatisfied),
#[error(transparent)]
Anyhow(#[from] anyhow::Error),
}
#[derive(Debug, Error)]
pub enum StackEvalError {
#[error(transparent)]
Instruction(#[from] IndexedInstructionError<InstructionEvalError>),
#[error(transparent)]
Anyhow(#[from] anyhow::Error),
}
#[derive(Debug, Error)]
#[error("Instruction ({instruction}) at index {index} failed: {error}")]
pub struct IndexedInstructionError<E> {
pub index: usize,
pub instruction: String,
pub error: E,
}
#[derive(Debug, Error)]
pub enum InstructionError {
#[error("Failed to evaluate: {0}")]
Eval(#[from] InstructionEvalError),
#[error("Failed to execute: {0}")]
Exec(#[from] InstructionExecError),
}
#[derive(Debug, Error)]
pub enum InstructionEvalError {
#[error(transparent)]
Eval(#[from] EvalError),
#[error("Call failed: {0}")]
Call(#[from] Box<CallEvalError>),
#[error(transparent)]
Anyhow(#[from] anyhow::Error),
}
#[derive(Debug, Error)]
pub enum InstructionExecError {
#[error("Call failed: {0}")]
Call(#[from] Box<CallExecError>),
#[error(transparent)]
Exec(#[from] ExecError),
#[error(transparent)]
Anyhow(#[from] anyhow::Error),
}
impl<E> IndexedInstructionError<E> {
pub fn new(index: usize, instruction: String, error: E) -> Self {
Self { index, instruction, error }
}
}