argmin/core/
errors.rs

1// Copyright 2018-2020 argmin developers
2//
3// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
5// http://opensource.org/licenses/MIT>, at your option. This file may not be
6// copied, modified, or distributed except according to those terms.
7
8//! # Errors
9
10use thiserror::Error;
11
12/// Argmin error type
13#[derive(Debug, Error)]
14pub enum ArgminError {
15    /// Indicates and invalid parameter
16    #[error("Invalid parameter: {text:?}")]
17    InvalidParameter {
18        /// Text
19        text: String,
20    },
21
22    /// Indicates that a function is not implemented
23    #[error("Not implemented: {text:?}")]
24    NotImplemented {
25        /// Text
26        text: String,
27    },
28
29    /// Indicates that a function is not initialized
30    #[error("Not initialized: {text:?}")]
31    NotInitialized {
32        /// Text
33        text: String,
34    },
35
36    /// Indicates that a condition is violated
37    #[error("Condition violated: {text:?}")]
38    ConditionViolated {
39        /// Text
40        text: String,
41    },
42
43    /// Checkpoint was not found
44    #[error("Checkpoint not found: {text:?}")]
45    CheckpointNotFound {
46        /// Text
47        text: String,
48    },
49
50    /// Indicates an impossible error
51    #[error("Impossible Error: {text:?}")]
52    ImpossibleError {
53        /// Text
54        text: String,
55    },
56}
57
58#[cfg(test)]
59mod tests {
60    use super::*;
61
62    send_sync_test!(error, ArgminError);
63}