diff --git a/giterated-models/src/object.rs b/giterated-models/src/object.rs index 3eddac4..4568873 100644 --- a/giterated-models/src/object.rs +++ b/giterated-models/src/object.rs @@ -80,8 +80,7 @@ impl< }, operation_state, ) - .await - .unwrap(); + .await?; Ok(serde_json::from_slice(&result).unwrap()) } diff --git a/giterated-models/src/settings/operations.rs b/giterated-models/src/settings/operations.rs index caabcac..853f031 100644 --- a/giterated-models/src/settings/operations.rs +++ b/giterated-models/src/settings/operations.rs @@ -40,4 +40,7 @@ impl GiteratedOperation for SetSetting { } #[derive(Error, Debug, Serialize, Deserialize, Clone)] -pub enum SetSettingError {} +pub enum SetSettingError { + #[error("Invalid setting `{0}` on object `{0}`")] + InvalidSetting(String, String) +} diff --git a/giterated-stack/src/handler/mod.rs b/giterated-stack/src/handler/mod.rs index 5a2d173..e811325 100644 --- a/giterated-stack/src/handler/mod.rs +++ b/giterated-stack/src/handler/mod.rs @@ -123,6 +123,7 @@ impl HandlerWrapper { F: Fn(&N, &StackOperationState) -> Result> + Clone + Send + Sync, R: std::fmt::Debug + 'static, E: Into> + 'static, + OperationError: From> + 'static, F: 'static, N: 'static, P: 'static, @@ -143,7 +144,7 @@ impl HandlerWrapper { let operation_state = operation_state; match (func)(predicate_output, state, operation_state).await { Ok(success) => Ok(success), - Err(_) => todo!(), + Err(err) => Err(err.into()), } } .boxed_local() diff --git a/giterated-stack/src/stack.rs b/giterated-stack/src/stack.rs index 015343f..f0d7323 100644 --- a/giterated-stack/src/stack.rs +++ b/giterated-stack/src/stack.rs @@ -8,7 +8,7 @@ use giterated_models::error::{GetValueError, IntoInternalError}; use giterated_models::message::GiteratedMessage; use giterated_models::object::NetworkAnyObject; use giterated_models::operation::NetworkAnyOperation; -use giterated_models::settings::{GetSettingError, Setting}; +use giterated_models::settings::{GetSettingError, Setting, SetSettingError}; use giterated_models::value::{GetValue, GiteratedObjectValue}; use giterated_models::{ error::OperationError, @@ -366,7 +366,8 @@ impl GiteratedStack { object_kind: &object_type, setting_name: &operation.setting_name, }) - .unwrap(); + // TODO: Check this + .ok_or(OperationError::Operation(serde_json::to_vec(&SetSettingError::InvalidSetting(operation.setting_name.clone(), object_type.clone())).as_internal_error()?))?; let setting = (setting_meta.deserialize)(operation.value) .as_internal_error_with_context(format!(