Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Commit

Permalink
feat: print error location with fmt (#497)
Browse files Browse the repository at this point in the history
  • Loading branch information
sirasistant authored Aug 18, 2023
1 parent 27a5a93 commit 575a9e5
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions acvm/src/pwg/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,26 @@ pub enum ErrorLocation {
Resolved(OpcodeLocation),
}

impl std::fmt::Display for ErrorLocation {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
ErrorLocation::Unresolved => write!(f, "unresolved"),
ErrorLocation::Resolved(location) => {
write!(f, "{location}")
}
}
}
}

#[derive(Clone, PartialEq, Eq, Debug, Error)]
pub enum OpcodeResolutionError {
#[error("cannot solve opcode: {0}")]
OpcodeNotSolvable(#[from] OpcodeNotSolvable),
#[error("backend does not currently support the {0} opcode. ACVM does not currently have a fallback for this opcode.")]
UnsupportedBlackBoxFunc(BlackBoxFunc),
#[error("Cannot satisfy constraint {opcode_location:?}")]
#[error("Cannot satisfy constraint {opcode_location}")]
UnsatisfiedConstrain { opcode_location: ErrorLocation },
#[error("Index out of bounds, array has size {array_size:?}, but index was {index:?}")]
#[error("Index out of bounds, array has size {array_size:?}, but index was {index:?} at {opcode_location}")]
IndexOutOfBounds { opcode_location: ErrorLocation, index: u32, array_size: u32 },
#[error("failed to solve blackbox function: {0}, reason: {1}")]
BlackBoxFunctionFailed(BlackBoxFunc, String),
Expand Down

0 comments on commit 575a9e5

Please sign in to comment.