From bbe22a305a0dd957352cdc15377594e2d03e30da Mon Sep 17 00:00:00 2001 From: jake Date: Fri, 18 Jun 2021 02:11:52 -0600 Subject: [PATCH] properly handle an error that doesn't even occur at the moment --- src/ship/items/inventory.rs | 7 ++++++- src/ship/items/manager.rs | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ship/items/inventory.rs b/src/ship/items/inventory.rs index 35cef9f..67bb356 100644 --- a/src/ship/items/inventory.rs +++ b/src/ship/items/inventory.rs @@ -82,6 +82,11 @@ pub enum InventoryItemAddToError { ExceedsCapacity, } +#[derive(Error, Debug, Clone)] +#[error("")] +pub enum InventoryAddError { +} + impl InventoryItem { pub fn entity_ids(&self) -> Vec { match self { @@ -511,7 +516,7 @@ impl CharacterInventory { .nth(0) } - pub fn add_item(&mut self, item: InventoryItem) -> Result<(), ()> { // TODO: errors + pub fn add_item(&mut self, item: InventoryItem) -> Result<(), InventoryAddError> { // TODO: errors // TODO: check slot conflict? self.items.push(item); Ok(()) diff --git a/src/ship/items/manager.rs b/src/ship/items/manager.rs index ff554ea..bfdcca6 100644 --- a/src/ship/items/manager.rs +++ b/src/ship/items/manager.rs @@ -917,7 +917,7 @@ impl ItemManager { entity_id: entity_id, item_id: item_id, item: ItemDetail::Weapon(weapon.clone()), - })); + }))?; entity_gateway.set_character_inventory(&character.id, &inventory.as_inventory_entity(&character.id)).await?;