MGI::SetTableColour(colour) => {
let ig = cs.check_acl(ag, ig, PCH::Instance, &[TP::ChangePieces])?.0;
- let colour: Colour = (&colour).try_into()?;
+ let colour: Colour = (&colour).try_into().map_err(|e| SpE::from(e))?;
ig.gs.table_colour = colour.clone();
(U{ pcs: vec![],
log: vec![ LogEntry {
Aggregated,
}
+#[derive(Error,Copy,Clone,Debug,Serialize,Deserialize)]
+#[error("Unsupported colour spec")]
+pub struct UnsupportedColourSpec;
+
#[derive(Error)]
pub struct InternalLogicError {
desc: Cow<'static, str>,
use otter_base::misc::display_as_debug;
use crate::accounts::AccountName;
+use crate::error::UnsupportedColourSpec;
use crate::gamestate::PieceSpec;
use crate::prelude::default;
#[derive(Error,Clone,Serialize,Deserialize,Debug)]
pub enum SpecError {
ImproperSizeSpec,
- UnsupportedColourSpec,
+ UnsupportedColourSpec(#[from] UnsupportedColourSpec),
FaceNotFound,
InternalError(String),
PosOffTable,
}
impl TryFrom<&ColourSpec> for Colour {
- type Error = SpecError;
- #[throws(SpecError)]
+ type Error = UnsupportedColourSpec;
+ #[throws(UnsupportedColourSpec)]
fn try_from(spec: &ColourSpec) -> Colour {
lazy_static! {
static ref RE: Regex = Regex::new(concat!(
}
let s = &spec.0;
if !RE.is_match(s) {
- throw!(SpecError::UnsupportedColourSpec);
+ throw!(UnsupportedColourSpec);
}
Html(spec.0.clone())
}