update stepper error mapping

This commit is contained in:
vms 2020-10-14 15:37:06 +03:00
parent d014bdbfc7
commit 05473672a1
2 changed files with 50 additions and 40 deletions

48
Cargo.lock generated
View File

@ -699,15 +699,6 @@ dependencies = [
"serde_json",
]
[[package]]
name = "fluence"
version = "0.2.8"
source = "git+https://github.com/fluencelabs/rust-sdk#4d6c4f6b862c22ebd8db7244daac0adf3f1bd2fd"
dependencies = [
"fluence-sdk-macro 0.2.8 (git+https://github.com/fluencelabs/rust-sdk)",
"fluence-sdk-main 0.2.8 (git+https://github.com/fluencelabs/rust-sdk)",
]
[[package]]
name = "fluence"
version = "0.2.8"
@ -718,6 +709,15 @@ dependencies = [
"fluence-sdk-main 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "fluence"
version = "0.2.8"
source = "git+https://github.com/fluencelabs/rust-sdk#4d6c4f6b862c22ebd8db7244daac0adf3f1bd2fd"
dependencies = [
"fluence-sdk-macro 0.2.8 (git+https://github.com/fluencelabs/rust-sdk)",
"fluence-sdk-main 0.2.8 (git+https://github.com/fluencelabs/rust-sdk)",
]
[[package]]
name = "fluence-app-service"
version = "0.1.9"
@ -753,14 +753,6 @@ dependencies = [
"wasmer-wasi-fl",
]
[[package]]
name = "fluence-sdk-macro"
version = "0.2.8"
source = "git+https://github.com/fluencelabs/rust-sdk#4d6c4f6b862c22ebd8db7244daac0adf3f1bd2fd"
dependencies = [
"fluence-sdk-wit 0.2.8 (git+https://github.com/fluencelabs/rust-sdk)",
]
[[package]]
name = "fluence-sdk-macro"
version = "0.2.8"
@ -771,13 +763,11 @@ dependencies = [
]
[[package]]
name = "fluence-sdk-main"
name = "fluence-sdk-macro"
version = "0.2.8"
source = "git+https://github.com/fluencelabs/rust-sdk#4d6c4f6b862c22ebd8db7244daac0adf3f1bd2fd"
dependencies = [
"fluence-sdk-macro 0.2.8 (git+https://github.com/fluencelabs/rust-sdk)",
"log",
"serde",
"fluence-sdk-wit 0.2.8 (git+https://github.com/fluencelabs/rust-sdk)",
]
[[package]]
@ -792,9 +782,20 @@ dependencies = [
]
[[package]]
name = "fluence-sdk-wit"
name = "fluence-sdk-main"
version = "0.2.8"
source = "git+https://github.com/fluencelabs/rust-sdk#4d6c4f6b862c22ebd8db7244daac0adf3f1bd2fd"
dependencies = [
"fluence-sdk-macro 0.2.8 (git+https://github.com/fluencelabs/rust-sdk)",
"log",
"serde",
]
[[package]]
name = "fluence-sdk-wit"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "560baf91197ded38a99a5c94ff366a3dd971ebf33f5d987ecce31d3dedf86d17"
dependencies = [
"proc-macro2",
"quote",
@ -807,8 +808,7 @@ dependencies = [
[[package]]
name = "fluence-sdk-wit"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "560baf91197ded38a99a5c94ff366a3dd971ebf33f5d987ecce31d3dedf86d17"
source = "git+https://github.com/fluencelabs/rust-sdk#4d6c4f6b862c22ebd8db7244daac0adf3f1bd2fd"
dependencies = [
"proc-macro2",
"quote",

View File

@ -40,8 +40,11 @@ pub enum StepperError {
/// Errors occurred while parsing aqua script in the form of S expressions.
SExprParseError(String),
/// Errors occurred while parsing supplied data.
DataSerdeError(String),
/// Errors occurred on aqua data deserialization.
DataDeserializationError(String),
/// Errors occurred on aqua data serialization.
DataSerializationError(String),
/// Errors occurred while parsing function arguments of an expression.
FuncArgsSerdeError(String),
@ -79,6 +82,9 @@ pub enum StepperError {
/// Multiple fold states found for such iterator name.
MultipleFoldStates(String),
/// Expected evidence state of different type.
InvalidEvidenceState(String),
/// Related to such ret_code that doesn't have match with current StepperError.
UnknownError(String),
}
@ -89,7 +95,8 @@ impl std::fmt::Display for StepperError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
match self {
StepperError::SExprParseError(err_msg) => write!(f, "{}", err_msg),
StepperError::DataSerdeError(err_msg) => write!(f, "{}", err_msg),
StepperError::DataDeserializationError(err_msg) => write!(f, "{}", err_msg),
StepperError::DataSerializationError(err_msg) => write!(f, "{}", err_msg),
StepperError::FuncArgsSerdeError(err_msg) => write!(f, "{}", err_msg),
StepperError::CallServiceSerdeError(err_msg) => write!(f, "{}", err_msg),
StepperError::CurrentPeerIdEnvError(err_msg) => write!(f, "{}", err_msg),
@ -102,6 +109,7 @@ impl std::fmt::Display for StepperError {
StepperError::MultipleValuesInJsonPath(err_msg) => write!(f, "{}", err_msg),
StepperError::FoldStateNotFound(err_msg) => write!(f, "{}", err_msg),
StepperError::MultipleFoldStates(err_msg) => write!(f, "{}", err_msg),
StepperError::InvalidEvidenceState(err_msg) => write!(f, "{}", err_msg),
StepperError::UnknownError(err_msg) => write!(f, "{}", err_msg),
}
}
@ -125,19 +133,21 @@ impl TryFrom<RawStepperOutcome> for StepperOutcome {
next_peer_pks: raw_outcome.next_peer_pks,
}),
1 => to_vm_error!(SExprParseError),
2 => to_vm_error!(DataSerdeError),
3 => to_vm_error!(FuncArgsSerdeError),
4 => to_vm_error!(CallServiceSerdeError),
5 => to_vm_error!(CurrentPeerIdEnvError),
6 => to_vm_error!(InstructionError),
7 => to_vm_error!(LocalServiceError),
8 => to_vm_error!(VariableNotFound),
9 => to_vm_error!(MultipleVariablesFound),
10 => to_vm_error!(VariableNotInJsonPath),
11 => to_vm_error!(IncompatibleJValueType),
12 => to_vm_error!(MultipleValuesInJsonPath),
13 => to_vm_error!(FoldStateNotFound),
14 => to_vm_error!(MultipleFoldStates),
2 => to_vm_error!(DataDeserializationError),
3 => to_vm_error!(DataSerializationError),
4 => to_vm_error!(FuncArgsSerdeError),
5 => to_vm_error!(CallServiceSerdeError),
6 => to_vm_error!(CurrentPeerIdEnvError),
7 => to_vm_error!(InstructionError),
8 => to_vm_error!(LocalServiceError),
9 => to_vm_error!(VariableNotFound),
10 => to_vm_error!(MultipleVariablesFound),
11 => to_vm_error!(VariableNotInJsonPath),
12 => to_vm_error!(IncompatibleJValueType),
13 => to_vm_error!(MultipleValuesInJsonPath),
14 => to_vm_error!(FoldStateNotFound),
15 => to_vm_error!(MultipleFoldStates),
16 => to_vm_error!(InvalidEvidenceState),
_ => to_vm_error!(UnknownError),
}
}