Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Commit

Permalink
more review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
lostman committed Sep 12, 2023
1 parent a6d3d88 commit 0af2583
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
27 changes: 12 additions & 15 deletions packages/fuel-indexer-lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ impl ExecutionSource {
}
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[derive(thiserror::Error, Debug, Clone, Copy, PartialEq, Eq)]
pub enum WasmIndexerError {
DeserializationError = 1,
DeserializationError = 0,
SerializationError,
PutObjectError,
UnableToSaveListType,
Expand All @@ -49,18 +49,17 @@ pub enum WasmIndexerError {
GeneralError,
}

impl From<i32> for WasmIndexerError {
fn from(value: i32) -> Self {
impl From<u32> for WasmIndexerError {
fn from(value: u32) -> Self {
match value {
0 => unreachable!("WasmIndexerError index starts at 1"),
1 => Self::DeserializationError,
2 => Self::SerializationError,
3 => Self::PutObjectError,
4 => Self::UnableToSaveListType,
5 => Self::UninitializedMemory,
6 => Self::UnableToFetchLogString,
7 => Self::KillSwitch,
8 => Self::DatabaseError,
0 => Self::DeserializationError,
1 => Self::SerializationError,
2 => Self::PutObjectError,
3 => Self::UnableToSaveListType,
4 => Self::UninitializedMemory,
5 => Self::UnableToFetchLogString,
6 => Self::KillSwitch,
7 => Self::DatabaseError,
_ => Self::GeneralError,
}
}
Expand Down Expand Up @@ -98,8 +97,6 @@ impl std::fmt::Display for WasmIndexerError {
}
}

impl std::error::Error for WasmIndexerError {}

/// Return a fully qualified indexer namespace.
pub fn fully_qualified_namespace(namespace: &str, identifier: &str) -> String {
format!("{}_{}", namespace, identifier)
Expand Down
2 changes: 1 addition & 1 deletion packages/fuel-indexer-tests/tests/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ async fn test_wasm_executor_can_meter_execution() {
}

#[tokio::test]
async fn test_wasm_executor_exit_codes() {
async fn test_wasm_executor_error_codes() {
use async_std::{fs::File, io::ReadExt};

if let Ok(mut current_dir) = std::env::current_dir() {
Expand Down
2 changes: 1 addition & 1 deletion packages/fuel-indexer/src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ fn put_many_to_many_record(

/// When called from WASM it will terminate the execution and return the error
/// code.
pub fn early_exit(err_code: i32) -> Result<(), WasmIndexerError> {
pub fn early_exit(err_code: u32) -> Result<(), WasmIndexerError> {
Err(WasmIndexerError::from(err_code))
}

Expand Down

0 comments on commit 0af2583

Please sign in to comment.