Skip to main content

mwalib/
error.rs

1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
5//! Structs and helper methods for Error handling
6
7use thiserror::Error;
8
9/// MwalibError subtypes
10#[derive(Error, Debug)]
11pub enum MwalibError {
12    /* // An error derived from `CfitsioError`.
13    #[error("{0}")]
14    Cfitsio(#[from] crate::fits_read::error::CfitsioError),*/
15    /// An error derived from `FitsError`.
16    #[error("{0}")]
17    Fits(#[from] crate::fits_read::error::FitsError),
18
19    /// An error derived from `BeamError`.
20    #[error("{0}")]
21    Beam(#[from] crate::voltage_beam::error::BeamError),
22
23    /// An error derived from `CalibrationFitError`.
24    #[error("{0}")]
25    CalibrationFit(#[from] crate::calibration_fit::error::CalibrationFitError),
26
27    /// An error derived from `CoarseChannel`.
28    #[error("{0}")]
29    CoarseChannel(#[from] crate::coarse_channel::error::CoarseChannelError),
30
31    /// An error dervied from `MetafitsError`.
32    #[error("{0}")]
33    Metafits(#[from] crate::metafits_context::error::MetafitsError),
34
35    /// An error derived from `RfinputError`.
36    #[error("{0}")]
37    Rfinput(#[from] crate::rfinput::error::RfinputError),
38
39    /// An error derived from `GpuboxError`.
40    #[error("{0}")]
41    Gpubox(#[from] crate::gpubox_files::error::GpuboxError),
42
43    /// An error derived from `VoltageFileError`.
44    #[error("{0}")]
45    Voltage(#[from] crate::voltage_files::error::VoltageFileError),
46
47    // An error associated with parsing a string into another type.
48    #[error("{source_file}:{source_line}\nCouldn't parse {key} in {fits_filename} HDU {hdu_num}")]
49    Parse {
50        key: String,
51        fits_filename: String,
52        hdu_num: usize,
53        source_file: String,
54        source_line: u32,
55    },
56}