Skip to content

Commit

Permalink
refactor(host): serialize into status error instead of manual
Browse files Browse the repository at this point in the history
  • Loading branch information
petarvujovic98 committed Aug 27, 2024
1 parent 8882c66 commit b505d94
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 7 additions & 2 deletions host/src/interfaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use raiko_tasks::{TaskManagerError, TaskStatus};
use tokio::sync::mpsc::error::TrySendError;
use utoipa::ToSchema;

use crate::server::api::v1::Status;

/// The standardized error returned by the Raiko host.
#[derive(thiserror::Error, Debug, ToSchema)]
pub enum HostError {
Expand Down Expand Up @@ -92,8 +94,11 @@ impl IntoResponse for HostError {
HostError::CapacityFull => ("capacity_full".to_string(), "".to_string()),
HostError::TaskManager(e) => ("task_manager".to_string(), e.to_string()),
};
axum::Json(serde_json::json!({ "status": "error", "error": error, "message": message }))
.into_response()
axum::Json(
serde_json::to_value(Status::Error { error, message })
.expect("couldn't serialize the error status"),
)
.into_response()
}
}

Expand Down
3 changes: 3 additions & 0 deletions script/integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ fi
# SGX
if [ "$1" == "sgx" ]; then
check_toolchain $TOOLCHAIN_SGX
if [ "$MOCK" = "1" ]; then
export SGX_DIRECT=1
fi
cargo ${TOOLCHAIN_SGX} test -F "sgx integration" run_scenarios_sequentially
fi

Expand Down

0 comments on commit b505d94

Please sign in to comment.