anise/
py_errors.rs

1/*
2 * ANISE Toolkit
3 * Copyright (C) 2021-onward Christopher Rabotin <christopher.rabotin@gmail.com> et al. (cf. AUTHORS.md)
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
7 *
8 * Documentation: https://nyxspace.com/
9 */
10
11use crate::almanac::metaload::MetaAlmanacError;
12use crate::almanac::planetary::PlanetaryDataError;
13use crate::analysis::AnalysisError;
14use crate::ephemerides::EphemerisError;
15use crate::errors::{AlmanacError, DecodingError, InputOutputError, IntegrityError, PhysicsError};
16use crate::orientations::OrientationError;
17use crate::structure::dataset::DataSetError;
18use core::convert::From;
19
20use pyo3::{exceptions::PyException, prelude::*};
21
22impl From<PhysicsError> for PyErr {
23    fn from(err: PhysicsError) -> PyErr {
24        PyException::new_err(err.to_string())
25    }
26}
27
28impl From<IntegrityError> for PyErr {
29    fn from(err: IntegrityError) -> PyErr {
30        PyException::new_err(err.to_string())
31    }
32}
33impl From<DecodingError> for PyErr {
34    fn from(err: DecodingError) -> PyErr {
35        PyException::new_err(err.to_string())
36    }
37}
38impl From<InputOutputError> for PyErr {
39    fn from(err: InputOutputError) -> PyErr {
40        PyException::new_err(err.to_string())
41    }
42}
43impl From<AlmanacError> for PyErr {
44    fn from(err: AlmanacError) -> PyErr {
45        PyException::new_err(err.to_string())
46    }
47}
48impl From<AnalysisError> for PyErr {
49    fn from(err: AnalysisError) -> PyErr {
50        PyException::new_err(err.to_string())
51    }
52}
53impl From<EphemerisError> for PyErr {
54    fn from(err: EphemerisError) -> PyErr {
55        PyException::new_err(err.to_string())
56    }
57}
58impl From<OrientationError> for PyErr {
59    fn from(err: OrientationError) -> PyErr {
60        PyException::new_err(err.to_string())
61    }
62}
63
64impl From<PlanetaryDataError> for PyErr {
65    fn from(err: PlanetaryDataError) -> PyErr {
66        PyException::new_err(err.to_string())
67    }
68}
69
70impl From<MetaAlmanacError> for PyErr {
71    fn from(err: MetaAlmanacError) -> PyErr {
72        PyException::new_err(err.to_string())
73    }
74}
75impl From<DataSetError> for PyErr {
76    fn from(err: DataSetError) -> PyErr {
77        PyException::new_err(err.to_string())
78    }
79}