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
//! Errors which can happen in various parts of the library.

use std::{borrow::Cow, fmt, fmt::Formatter, sync::mpsc::SendError};

use lyon::tessellation::TessellationError;

use crate::render::{error::RenderError, graph::RenderGraphError};

/// Enumeration of errors which can happen during the operation of the library.
#[derive(Debug)]
pub enum Error {
    APC,
    Scheduler,
    Network(String),
    Tesselation(TessellationError),
    Render(RenderError),
    Generic(Cow<'static, str>),
}

impl<E> From<E> for Error
where
    E: Into<RenderError>,
{
    fn from(e: E) -> Self {
        Error::Render(e.into())
    }
}

impl From<TessellationError> for Error {
    fn from(e: TessellationError) -> Self {
        Error::Tesselation(e)
    }
}

impl<T> From<SendError<T>> for Error {
    fn from(_e: SendError<T>) -> Self {
        Error::Scheduler
    }
}