sky_save/
error.rs

1//! The library's error type.
2
3use std::io;
4use thiserror::Error;
5
6/// An error that can occur when loading a save file.
7#[derive(Debug, Default, Error)]
8pub enum SaveError {
9    #[default]
10    #[error("Unknown error")]
11    Unknown,
12
13    #[error("Error loading save file: {0:?}")]
14    Io(#[from] io::Error),
15
16    #[error("File size must be at least 128Kib.")]
17    InvalidSize,
18
19    #[error(
20        "Invalid save checksum in neither primary or backup save blocks:\n\
21        Primary: expected {pri_expected:?}, Found: {pri_found:?}\n\
22        Backup: expected {bak_expected:?}, Found: {bak_found:?}"
23    )]
24    InvalidChecksum {
25        pri_expected: [u8; 4],
26        pri_found: [u8; 4],
27        bak_expected: [u8; 4],
28        bak_found: [u8; 4],
29    },
30}
31
32/// An error that can occur when encoding or decoding PMD strings.
33#[derive(Debug, Error)]
34pub enum EncodingError {
35    #[error("Invalid PMD character: {0}")]
36    InvalidPmdCharacter(String),
37    #[error("PMD String must not exceed 10 characters")]
38    InvalidPmdStringLen,
39}