diff --git a/src/command/command.rs b/src/command/command.rs index 509ae8f..7461380 100644 --- a/src/command/command.rs +++ b/src/command/command.rs @@ -7,6 +7,7 @@ use crate::command::{CommandNew, CommandSet, Parse, ParserError}; use crate::database::Db; use crate::queue::SendQueue; use crate::result::RudeResult; +use crate::try_log; /// Root level of command. /// @@ -76,11 +77,13 @@ impl Parse for Command { fn parse_subcommand(&self, s: String) -> RudeResult<(Self, String)> { match self { Self::New(_) => { - let (command, args) = CommandNew::parse(s)?; + let (command, args) = + try_log!(CommandNew::parse(s), "Unable to parse new subcommand"); Ok((Self::New(command), args)) } Self::Set(_) => { - let (command, args) = CommandSet::parse(s)?; + let (command, args) = + try_log!(CommandSet::parse(s), "Unable to parse set subcommand"); Ok((Self::Set(command), args)) } Self::Default => Err(ParserError::Default.into()), diff --git a/src/command/set/room/room.rs b/src/command/set/room/room.rs index 63041db..1f539eb 100644 --- a/src/command/set/room/room.rs +++ b/src/command/set/room/room.rs @@ -7,6 +7,7 @@ use crate::command::{CommandSetRoomDescription, Parse, ParserError}; use crate::database::Db; use crate::queue::SendQueue; use crate::result::RudeResult; +use crate::try_log; /// Set room properties #[derive(Clone, Debug, Display, EnumIter, Eq, Ord, PartialEq, PartialOrd)] @@ -42,7 +43,10 @@ impl Parse for CommandSetRoom { fn parse_subcommand(&self, s: String) -> RudeResult<(Self, String)> { match self { Self::Description(_) => { - let (command, args) = CommandSetRoomDescription::parse(s)?; + let (command, args) = try_log!( + CommandSetRoomDescription::parse(s), + "Unable to parse room description command" + ); Ok((Self::Description(command), args)) } Self::Default => Err(ParserError::Default.into()), diff --git a/src/command/set/set.rs b/src/command/set/set.rs index 725f7bf..2adf5b3 100644 --- a/src/command/set/set.rs +++ b/src/command/set/set.rs @@ -7,6 +7,7 @@ use crate::command::{CommandSetPlayer, CommandSetRoom, CommandSetZone, Parse, Pa use crate::database::Db; use crate::queue::SendQueue; use crate::result::RudeResult; +use crate::try_log; /// Set various options #[derive(Clone, Debug, Display, EnumIter, Eq, Ord, PartialEq, PartialOrd)] @@ -42,15 +43,20 @@ impl Parse for CommandSet { fn parse_subcommand(&self, s: String) -> RudeResult<(Self, String)> { match self { Self::Player(_) => { - let (command, args) = CommandSetPlayer::parse(s)?; + let (command, args) = try_log!( + CommandSetPlayer::parse(s), + "Unable to parse player subcommand", + ); Ok((Self::Player(command), args)) } Self::Room(_) => { - let (command, args) = CommandSetRoom::parse(s)?; + let (command, args) = + try_log!(CommandSetRoom::parse(s), "Unable to parse room subcommand",); Ok((Self::Room(command), args)) } Self::Zone(_) => { - let (command, args) = CommandSetZone::parse(s)?; + let (command, args) = + try_log!(CommandSetZone::parse(s), "Unable to parse zone subcommand",); Ok((Self::Zone(command), args)) } Self::Default => Err(ParserError::Default.into()), diff --git a/src/server.rs b/src/server.rs index 7d336f9..8f02a44 100644 --- a/src/server.rs +++ b/src/server.rs @@ -10,6 +10,7 @@ use mio::{Interest, Registry, Token}; use crate::client::Client; use crate::result::*; use crate::state::*; +use crate::try_log; /// Connection information for the server. #[derive(Debug)] @@ -44,7 +45,7 @@ impl Server { /// Accept a new client connection pub fn accept(&self, token: Token) -> RudeResult { - let (socket, addr) = self.socket.accept()?; + let (socket, addr) = try_log!(self.socket.accept(), "Unable to accept socket"); Ok(Client { socket, diff --git a/src/world/zone.rs b/src/world/zone.rs index d954357..ea045ff 100644 --- a/src/world/zone.rs +++ b/src/world/zone.rs @@ -7,6 +7,7 @@ use rusqlite::Row; use serde_derive::{Deserialize, Serialize}; use crate::id::Id; +use crate::try_log; use crate::world::{Area, AreaType}; /// A collection of rooms and/or other zones. @@ -77,10 +78,13 @@ impl<'a> TryFrom<&Row<'a>> for Zone { fn try_from(row: &Row) -> Result { Ok(Self { - id: row.get("id")?, - parent: row.get("parent")?, - name: row.get("name")?, - users_visible: row.get("users_visible")?, + id: try_log!(row.get("id"), "Unable to get id from row"), + parent: try_log!(row.get("parent"), "Unable to get parent from row"), + name: try_log!(row.get("name"), "Unable to get name from row"), + users_visible: try_log!( + row.get("users_visible"), + "Unable to get users_visible from row" + ), areas: HashSet::new(), }) }