1use crate::ode::*;
5
6use std::fmt;
7use std::error::Error;
8
9#[derive(Debug)]
11pub struct ODEError {
12 msg: String
13}
14
15impl ODEError {
17 pub fn no_key(k: String) -> ODEError {
19 ODEError{msg: format!("no key [{}] in mbgs", k)}
20 }
21
22 pub fn no_id(id: dBodyID) -> ODEError {
24 ODEError{msg: format!("no id {:018p} in obgs", id)}
25 }
26
27 pub fn no_mgm_id(id: dGeomID) -> ODEError {
29 ODEError{msg: format!("no mgm id {:018p} in mgms", id)}
30 }
31}
32
33impl fmt::Display for ODEError {
35 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
37 write!(f, "ODEError: {}", self.msg)
38 }
39}
40
41impl Error for ODEError {
43 fn source(&self) -> Option<&(dyn Error + 'static)> {
45 Some(self)
46 }
47}