mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
e852e0cfab
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.
28 lines
871 B
Rust
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) }
|
|
}
|