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
//! Object based errors.

//use std::{error::Error, io::ErrorKind};
use thiserror::Error;

/// This error gets returned when the layer that gets specified when an object needs to get added
/// doesn't exit in the objects list anymore.
#[derive(Error, Debug)]
#[error("No Layer found")]
pub struct NoLayerError;

/// This error gets returned when one of the objects input into register_joint doesn't have a rigid body to attach the joint to.
#[derive(Error, Debug)]
#[error("One of the objects does not have a rigid body")]
pub struct NoRigidBodyError;

#[derive(Error, Debug)]
#[error("This joint was not found in this layer.")]
pub struct NoJointError;

/// Errors that happen in object and layer functions.
#[derive(Error, Debug)]
pub enum ObjectError {
    /// The move operation has failed.
    #[error("This object can not be moved to this position:\n{0}")]
    Move(String),
    /// This object for some reason does not have a parent..
    #[error("This object does not have a parent, so this operation can not be applied.")]
    NoParent,
}