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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
//! Errors that can occur in Birli
use marlu::{io::error::BadArrayShape, mwalib};
#[cfg(feature = "cli")]
use shlex::QuoteError;
use thiserror::Error;
use crate::{
corrections::{DigitalGainCorrection, PassbandCorrection},
van_vleck::VanVleckCorrection,
};
/// Errors relating to CI
#[cfg(feature = "cli")]
#[derive(Error, Debug)]
#[allow(clippy::upper_case_acronyms)]
pub enum CLIError {
#[error("Invalid Command Line Argument: option {option} expected {expected} but received {received}")]
/// When a bad CLI argument is provided
InvalidCommandLineArgument {
/// The option for which the argument was provided
option: String,
/// The argument that was expected
expected: String,
/// The argument that was received instead
received: String,
},
#[error("Invalid range specifier: {reason}")]
/// When a bad range specifier is provided
InvalidRangeSpecifier {
/// Why the range is invalid
reason: String,
},
}
/// An enum of all the errors possible in Birli
#[derive(Error, Debug)]
#[allow(clippy::upper_case_acronyms)]
pub enum BirliError {
#[error(transparent)]
/// Error derived from [`crate::io::error::IOError`]
IOError(#[from] crate::io::error::IOError),
#[error(transparent)]
/// Error derived from [`crate::calibration::CalibrationError`]
CalibrationError(#[from] crate::calibration::CalibrationError),
#[cfg(feature = "cli")]
#[error(transparent)]
/// Error derived from [`QuoteError`]
QuoteError(#[from] QuoteError),
#[cfg(feature = "cli")]
#[error(transparent)]
/// Error derived from [`clap::Error`]
ClapError(#[from] clap::Error),
#[cfg(feature = "cli")]
#[error(transparent)]
/// Error derived from `CLIError`
CLIError(#[from] CLIError),
#[error(transparent)]
/// Error derived from [`marlu::mwalib::MwalibError`]
MwalibError(#[from] mwalib::MwalibError),
#[error(transparent)]
/// Error derived from [`crate::marlu::selection::SelectionError`]
SelectionError(#[from] marlu::selection::SelectionError),
#[error(transparent)]
/// Error derived from [`crate::corrections::PassbandCorrection`]
PassbandCorrection(#[from] PassbandCorrection),
#[error(transparent)]
/// Error derived from [`crate::corrections::DigitalGainCorrection`]
DigitalGainCorrection(#[from] DigitalGainCorrection),
#[error(transparent)]
/// Error derived from [`crate::van_vleck::VanVleckCorrection`]
VanVleckCorrection(#[from] VanVleckCorrection),
#[error("You selected dry run")]
/// enum variant for when a dry run is selected
DryRun {},
#[error(transparent)]
/// Error for bad array shape in provided argument
BadArrayShape(#[from] BadArrayShape),
#[error("Insufficient memory available; need {need_gib} GiB of memory.\nPlease specify the maximum amount of memory to use.")]
/// Error when we asked for too much memory
InsufficientMemory {
/// The amount of memory we think we need
need_gib: usize,
},
#[error("Invalid MWA Version ({version}): {message}")]
/// When a bad MWA Version is provided
BadMWAVersion {
/// The message to display
message: String,
/// The version that was provided
version: String,
},
}