implement formatting for game errors
This commit is contained in:
parent
fe690a6d9b
commit
b868ee4d04
14
src/game.rs
14
src/game.rs
|
@ -4,6 +4,8 @@ use std::str::FromStr;
|
|||
use std::collections::HashMap;
|
||||
use std::borrow::BorrowMut;
|
||||
use crate::image::Image;
|
||||
use std::fmt;
|
||||
use std::fmt::Display;
|
||||
|
||||
/// in very early versions of Bitsy, room tiles were defined as single alphanumeric characters -
|
||||
/// so there was a maximum of 36 unique tiles. later versions are comma-separated.
|
||||
|
@ -77,6 +79,18 @@ pub enum NotFound {
|
|||
Tile,
|
||||
}
|
||||
|
||||
impl Display for NotFound {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f,"Not found: {} data", match self {
|
||||
&NotFound::Anything => "game",
|
||||
&NotFound::Avatar => "avatar",
|
||||
&NotFound::Room => "room",
|
||||
&NotFound::Sprite => "sprite",
|
||||
&NotFound::Tile => "tile",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct Game {
|
||||
pub name: String,
|
||||
|
|
Loading…
Reference in New Issue