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
//! All possible errors that can happen in the engine.


use crate::{renderer::error::RendererError, sound::error::SoundError};
use glutin::{ContextError, CreationError};

/// See module docs.

#[derive(Debug)]
pub enum EngineError {
    /// Sound system error.

    Sound(SoundError),
    /// Rendering system error.

    Renderer(RendererError),
    /// OpenGL context creation error.

    ContextCreationError(CreationError),
    /// Runtime OpenGL context error.

    ContextError(ContextError),
}

impl From<SoundError> for EngineError {
    fn from(sound: SoundError) -> Self {
        Self::Sound(sound)
    }
}

impl From<RendererError> for EngineError {
    fn from(renderer: RendererError) -> Self {
        Self::Renderer(renderer)
    }
}

impl From<CreationError> for EngineError {
    fn from(e: CreationError) -> Self {
        Self::ContextCreationError(e)
    }
}

impl From<ContextError> for EngineError {
    fn from(e: ContextError) -> Self {
        Self::ContextError(e)
    }
}