Avoid a panic when downcasting to redjubjub::Error fails (#1363)
Instead, format the original error as a string, to provide better diagnostics. Temporary fix for #1357, the permanent fix ticket is #1186.
This commit is contained in:
parent
6202cb45b1
commit
2d60c00fb0
|
@ -67,13 +67,20 @@ pub enum TransactionError {
|
|||
|
||||
#[error("bindingSig MUST represent a valid signature under the transaction binding validating key bvk of SigHash")]
|
||||
RedJubjub(redjubjub::Error),
|
||||
|
||||
// temporary error type until #1186 is fixed
|
||||
#[error("Downcast from BoxError to redjubjub::Error failed")]
|
||||
InternalDowncastError(String),
|
||||
}
|
||||
|
||||
impl From<BoxError> for TransactionError {
|
||||
fn from(err: BoxError) -> Self {
|
||||
match err.downcast::<redjubjub::Error>() {
|
||||
Ok(e) => TransactionError::RedJubjub(*e),
|
||||
Err(e) => panic!(e),
|
||||
Err(e) => TransactionError::InternalDowncastError(format!(
|
||||
"downcast to redjubjub::Error failed, original error: {:?}",
|
||||
e
|
||||
)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue