1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
use crate::Id; #[derive(Debug, Fail)] pub enum AddViewError { #[fail(display = "some error occured")] GenericError {}, } #[derive(Debug, Fail)] pub enum RemoveViewError { #[fail(display = "invalid id given, cannot be removed: {}", id)] InvalidId { id: Id }, #[fail(display = "id has no parent, cannot be removed: {}", id)] NoParent { id: Id }, #[fail(display = "something broke, oh no ")] Generic {}, } #[derive(Debug, Fail)] pub enum SwitchError { #[fail(display = "node {} has no parent to be switched to from {}", from, to)] NoParent { from: Id, to: Id }, #[fail(display = "error while switching, figuring out...")] Failed {}, } impl std::convert::From<indextree::NodeError> for SwitchError { fn from(_error: indextree::NodeError) -> Self { SwitchError::Failed {} } } impl std::convert::From<failure::Error> for RemoveViewError { fn from(_error: failure::Error) -> Self { RemoveViewError::Generic {} } } impl std::convert::From<failure::Error> for AddViewError { fn from(_error: failure::Error) -> Self { AddViewError::GenericError {} } }