veloren/server/src/persistence/error.rs
Shane Handley e852e0cfab - Update the stats of characters individually, reverting the change with
big combined updates.
- Add a timer to the stats persistence system and change the frequency
that it runs to 10s
- Seperate the loading of character data for the character list during
selection, and the full data we will grab during state creation. Ideally
additional persisted bits can get returned at the same point and added
to the ecs within the same block.
2020-05-13 09:14:09 +10:00

28 lines
871 B
Rust

extern crate diesel;
use std::fmt;
#[derive(Debug)]
pub enum Error {
// The player has already reached the max character limit
CharacterLimitReached,
// An error occured when performing a database action
DatabaseError(diesel::result::Error),
// Unable to load body or stats for a character
CharacterDataError,
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", match self {
Self::DatabaseError(diesel_error) => diesel_error.to_string(),
Self::CharacterLimitReached => String::from("Character limit exceeded"),
Self::CharacterDataError => String::from("Error while loading character data"),
})
}
}
impl From<diesel::result::Error> for Error {
fn from(error: diesel::result::Error) -> Error { Error::DatabaseError(error) }
}