#[error(r#"unsupported bundle, library or spec format version "format={0}""#)]
pub struct Unsupported(u32);
+#[derive(Error,Debug,Copy,Clone,Serialize,Deserialize)]
+pub struct Incompat<E> {
+ mformat: Version,
+ error: E,
+}
+impl<E> Display for Incompat<E> where E: Display {
+ #[throws(fmt::Error)]
+ fn fmt(&self, f: &mut fmt::Formatter) {
+ if self.mformat == 1 {
+ write!(f,
+ r#"{}: not supported in format 1, maybe you forgoot "format="#,
+ self.error)?;
+ } else {
+ write!(f,
+ r#"{}: not supported with "format={}""#,
+ self.error, self.mformat)?;
+ }
+ }
+}
+impl Version {
+ pub fn incompat<E>(self, error: E) -> Incompat<E> {
+ Incompat { mformat: self, error }
+ }
+
+ pub fn err_mapper<E>(self) -> impl Fn(E) -> Incompat<E> {
+ move |error| self.incompat(error)
+ }
+}
+
#[derive(Error,Debug,Clone,Copy,Serialize,Deserialize)]
#[derive(Eq,PartialEq)]
pub enum VersionError {
FilesListFieldsMustBeAtStart(usize),
#[error("piece defines multiple faces in multiple ways")]
MultipleMultipleFaceDefinitions,
+ #[error("{0}")]
+ MaterialsFormatIncompat(#[from] materials_format::Incompat<
+ LibraryLoadMFIncompat
+ >),
#[error("{0}")] BadSubstitution(#[from] SubstError),
#[error("{0}")] UnsupportedColourSpec(#[from] UnsupportedColourSpec),
#[error("bad item name (invalid characters) in {0:?}")] BadItemName(String),
#[error("{0:?}")] MaterialsFormatVersionError(#[from] MFVE),
}
+#[derive(Error,Debug,Clone,Copy,Serialize,Deserialize)]
+pub enum LibraryLoadMFIncompat {
+ #[error("bad scale definition")] Scale,
+}
+pub use LibraryLoadMFIncompat as LLMI;
+
#[derive(Error,Copy,Clone,Debug)]
pub enum SubstErrorKind {
#[error("missing or unrecognised token {0}")] MissingToken (&'static str),