Closed lordshashank closed 6 months ago
@marioiordanov is this what you meant (I took sierra errors from cairo_lang_starknet_classes, as cairo_lang_starknet had just abi errors in it) ? I have also not removed the "reason" property, let me know if you want it removed.
@lordshashank just make it as TransactionExecutionError(#[from] TransactionExecutionError)
@marioiordanov did that as following
#[error(transparent)]
SierraCompilationError(#[from] StarknetSierraCompilationError),
Now, I tried to use ?
to auto parse error here but its not working, should I use StarknetSierraCompilationError variants here?
@lordshashank take a look at other error variants that have the same structure
@marioiordanov , I have looked into the other variants, thing is StarknetSierraCompilationError has many variants here, Would downcasting work here so as to get the variant automatically like this
let casm_json = usc::compile_contract(serde_json::to_value(sierra_contract_class).map_err(
|err| Error::JsonError(JsonError::Custom { msg: err.to_string() }),
)?).map_err(|err| {
let err_str = err.to_string();
if let Some(sierra_error) = err.downcast::<StarknetSierraCompilationError>().ok() {
Error::SierraCompilationError(sierra_error)
} else {
Error::UnexpectedError(err_str)
}
})?;
or should I use some specific variant only?
@lordshashank sorry about misleading you, just add a String to the SierraCompilationError variant and then create the variant like this: Error::SierraCompilationError(err_str)
@marioiordanov I don't understand, do you want StarknetSierraCompilationError Error derivation for SierraCompilationError to be removed here and just make variant from string message, if thats the case, it is already like that in repo's current state, then what changes do we intend to do in the issue?
I just saw that there are two SierraCompilationError variants in different crates. Replace usage of SierraCompilationError variant from starknet_devnet_core::errors::Error with TypesError(starknet_devnet_types::error::Error::SierraCompilationError). Then delete the variant from starknet_devnet_core
@marioiordanov did that, let me know if something else is to be done here.
@marioiordanov should we change issue description if this is all to be done?
@lordshashank we will just make a comment. Have to run the CI to approve your PR
Ok let me know if CI fails.
Usage related changes
improves error handling
Development related changes
Resolves https://github.com/0xSpaceShard/starknet-devnet-rs/issues/198
Checklist:
./scripts/format.sh
./scripts/clippy_check.sh
./scripts/check_unused_deps.sh