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

View File

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