Skip to content

Commit

Permalink
just panic
Browse files Browse the repository at this point in the history
  • Loading branch information
YaroShkvorets committed Mar 17, 2024
1 parent 895e4ed commit 4610a77
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions antelope.trxstats/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ fn parse_params(input: String) -> Result<Params, SubstreamsError> {
for param in input.split('&') {
let (key, value) = param
.split_once('=')
.ok_or_else(|| SubstreamsError::Unexpected(format!("Invalid parameter format: {}", param)))?;
.expect(format!("Invalid parameter format: {}", param).as_str());
let parsed_value = value
.parse::<u32>()
.map_err(|_| SubstreamsError::Unexpected(format!("Invalid param value for key '{}'", key)))?;
.expect(format!("Invalid param value for key '{}'", key).as_str());

match key {
"cpu_elapsed" => result.cpu_elapsed = parsed_value,
"net_elapsed" => result.net_elapsed = parsed_value,
"cpu_usage" => result.cpu_usage = parsed_value,
"net_usage" => result.net_usage = parsed_value,
"action_count" => result.action_count = parsed_value,
_ => return Err(SubstreamsError::Unexpected(format!("Unknown parameter: '{}'", key))),
_ => panic!("Unknown parameter: '{}'", key),
}
}

Expand Down

0 comments on commit 4610a77

Please sign in to comment.