diff --git a/savestate/src/error.rs b/savestate/src/error.rs index ec79f89..7129fcf 100644 --- a/savestate/src/error.rs +++ b/savestate/src/error.rs @@ -13,6 +13,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . +use std::fmt; use pkstrings::Error as PKStringError; use std::array::TryFromSliceError; use std::io::Error as IOError; @@ -48,3 +49,20 @@ impl From for Error { Error::PKString(err) } } + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { + match self { + Error::InvalidSaveLength => write!(f, "Invalid save length"), + Error::InvalidChecksum => write!(f, "Invalid checksum"), + Error::InvalidListEnd => write!(f, "Invalid expected end of list"), + Error::InvalidPokemonTypes => write!(f, "Invalid Pokémon Types"), + Error::InvalidPokemonStatus => write!(f, "Invalid Pokémon Status"), + Error::InvalidPokemonMove => write!(f, "Invalid Pokémon Move"), + Error::InvalidPokemonMovePPUp(pp) => write!(f, "Invalid Pokémon PP: {:x?}", pp), + Error::IO(err) => write!(f, "{}", err), + Error::Array(err) => write!(f, "{}", err), + Error::PKString(err) => write!(f, "{}", err), + } + } +}