use std::fmt;
use std::io;
use std::path::PathBuf;
#[ derive( Debug ) ]
pub enum ThemeError
{
Io( PathBuf, io::Error ),
ParseJson( PathBuf, serde_json::Error ),
NotFound( String ),
InvalidColor( String ),
UnknownColorRef( String ),
}
impl fmt::Display for ThemeError
{
fn fmt( &self, f: &mut fmt::Formatter<'_> ) -> fmt::Result
{
match self
{
ThemeError::Io( p, e ) => write!( f, "reading {}: {}", p.display(), e ),
ThemeError::ParseJson( p, e ) => write!( f, "parsing {}: {}", p.display(), e ),
ThemeError::NotFound( id ) => write!( f, "theme `{}` not found in any search path", id ),
ThemeError::InvalidColor( s ) => write!( f, "invalid colour `{}` (expected #RRGGBB, #RRGGBBAA or rgb[a](…))", s ),
ThemeError::UnknownColorRef( s ) => write!( f, "unknown reference `@{}` (not defined in top-level `colors`, `gradients` or `inset_stacks`)", s ),
}
}
}
impl std::error::Error for ThemeError {}