implement formatting for game errors

This commit is contained in:
Max Bradbury 2020-09-25 16:58:30 +01:00
parent fe690a6d9b
commit b868ee4d04
1 changed files with 14 additions and 0 deletions

View File

@ -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,