migrate from anyhow to thiserror (#197)
* migrate from anyhow to thiserror (#190). pending polish error msgs * Add backtrace and compartmentalize errors - Include backtraces in the errors we generate. To get this we can't just return a literal enum, because the backtrace requires a call. - Related to the previous point: add methods to create errors so we can include the backtrace conveniently without changing too much the syntax. So instead of `Err(Error::KeyNotFound(key))` (literal enum) it will be `Err(Error::key_not_found(key))` (method call) - Each error should be local to its scope, and each scope should only return its own error. - The merkle tree should return `TreeError` and not Error - The middleware should return `MiddlewareError` and not Error - With a global Error we can't easily include backend/frontend types in the error fields, so declare a `BackendError` and a `FrontendError` and follow the pattern from the previous point - The Pod traits should be able to return backend errors and will be used in the frontend; for that we change them to use trait object Error: `dyn std::error::Error` * fix error * apply suggestions from @arnaucube * rename XError and XResult to Error and Result * reorg signature * make frontend custom error more ergonomic * remove unnecessary feature --------- Co-authored-by: Eduard S. <eduardsanou@posteo.net>
This commit is contained in:
parent
58d3c6a236
commit
29545f03fc
31 changed files with 696 additions and 273 deletions
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
use std::{array, iter};
|
||||
|
||||
use anyhow::Result;
|
||||
use plonky2::{
|
||||
field::{
|
||||
extension::Extendable,
|
||||
|
|
@ -19,6 +18,7 @@ use plonky2::{
|
|||
use crate::{
|
||||
backends::plonky2::{
|
||||
basetypes::D,
|
||||
error::Result,
|
||||
mainpod::{Operation, OperationArg, Statement},
|
||||
primitives::merkletree::MerkleClaimAndProofTarget,
|
||||
},
|
||||
|
|
@ -75,7 +75,7 @@ impl StatementArgTarget {
|
|||
params: &Params,
|
||||
arg: &StatementArg,
|
||||
) -> Result<()> {
|
||||
pw.set_target_arr(&self.elements, &arg.to_fields(params))
|
||||
Ok(pw.set_target_arr(&self.elements, &arg.to_fields(params))?)
|
||||
}
|
||||
|
||||
fn new(first: ValueTarget, second: ValueTarget) -> Self {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
use anyhow::Result;
|
||||
use itertools::zip_eq;
|
||||
use plonky2::{
|
||||
hash::{hash_types::HashOutTarget, poseidon::PoseidonHash},
|
||||
|
|
@ -16,6 +15,7 @@ use crate::{
|
|||
},
|
||||
signedpod::{SignedPodVerifyGadget, SignedPodVerifyTarget},
|
||||
},
|
||||
error::Result,
|
||||
mainpod,
|
||||
primitives::merkletree::{
|
||||
MerkleClaimAndProof, MerkleClaimAndProofTarget, MerkleProofGadget,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
use std::iter;
|
||||
|
||||
use anyhow::Result;
|
||||
use itertools::Itertools;
|
||||
use plonky2::{
|
||||
hash::hash_types::{HashOut, HashOutTarget},
|
||||
|
|
@ -15,6 +14,7 @@ use crate::{
|
|||
backends::plonky2::{
|
||||
basetypes::D,
|
||||
circuits::common::{CircuitBuilderPod, StatementArgTarget, StatementTarget, ValueTarget},
|
||||
error::Result,
|
||||
primitives::{
|
||||
merkletree::{
|
||||
MerkleClaimAndProof, MerkleProofExistenceGadget, MerkleProofExistenceTarget,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue