kasuari/
error.rs

1use thiserror::Error;
2
3use crate::InternalSolverError;
4
5/// The possible error conditions that `Solver::add_constraint` can fail with.
6#[derive(Debug, Copy, Clone, Error)]
7pub enum AddConstraintError {
8    /// The constraint specified has already been added to the solver.
9    #[error("The constraint specified has already been added to the solver.")]
10    DuplicateConstraint,
11
12    /// The constraint is required, but it is unsatisfiable in conjunction with the existing
13    /// constraints.
14    #[error("The constraint is required, but it is unsatisfiable in conjunction with the existing constraints.")]
15    UnsatisfiableConstraint,
16
17    /// The solver entered an invalid state.
18    #[error("The solver entered an invalid state. If this occurs please report the issue.")]
19    InternalSolverError(#[from] InternalSolverError),
20}
21
22/// The possible error conditions that `Solver::remove_constraint` can fail with.
23#[derive(Debug, Copy, Clone, Error)]
24pub enum RemoveConstraintError {
25    /// The constraint specified was not already in the solver, so cannot be removed.
26    #[error("The constraint specified was not already in the solver, so cannot be removed.")]
27    UnknownConstraint,
28
29    /// The solver entered an invalid state. If this occurs please report the issue. This variant
30    /// specifies additional details as a string.
31    #[error("The solver entered an invalid state. If this occurs please report the issue.")]
32    InternalSolverError(#[from] InternalSolverError),
33}
34
35/// The possible error conditions that `Solver::add_edit_variable` can fail with.
36#[derive(Debug, Copy, Clone, Error)]
37pub enum AddEditVariableError {
38    /// The specified variable is already marked as an edit variable in the solver.
39    #[error("The specified variable is already marked as an edit variable in the solver.")]
40    DuplicateEditVariable,
41
42    /// The specified strength was `REQUIRED`. This is illegal for edit variable strengths.
43    #[error("The specified strength was `REQUIRED`. This is illegal for edit variable strengths.")]
44    BadRequiredStrength,
45}
46
47/// The possible error conditions that `Solver::remove_edit_variable` can fail with.
48#[derive(Debug, Copy, Clone, Error)]
49pub enum RemoveEditVariableError {
50    /// The specified variable was not an edit variable in the solver, so cannot be removed.
51    #[error(
52        "The specified variable was not an edit variable in the solver, so cannot be removed."
53    )]
54    UnknownEditVariable,
55
56    /// The solver entered an invalid state. If this occurs please report the issue. This variant
57    /// specifies additional details as a string.
58    #[error("The solver entered an invalid state. If this occurs please report the issue.")]
59    InternalSolverError(#[from] InternalSolverError),
60}
61
62/// The possible error conditions that `Solver::suggest_value` can fail with.
63#[derive(Debug, Copy, Clone, Error)]
64pub enum SuggestValueError {
65    /// The specified variable was not an edit variable in the solver, so cannot have its value
66    /// suggested.
67    #[error(
68        "The specified variable was not an edit variable in the solver, so cannot have its value suggested."
69    )]
70    UnknownEditVariable,
71
72    /// The solver entered an invalid state. If this occurs please report the issue. This variant
73    /// specifies additional details as a string.
74    #[error("The solver entered an invalid state. If this occurs please report the issue.")]
75    InternalSolverError(#[from] InternalSolverError),
76}