Skip to main content

xcsp3_serde/
error.rs

1//! Error types for the XCSP3 serde crate.
2
3use thiserror::Error;
4
5#[derive(Clone, Debug, Error)]
6/// Error type returned when instantiating a [`Group`](crate::constraint::Group)
7/// or [`Slide`](crate::constraint::Slide) fails.
8pub enum UnrollError {
9	#[error("placeholder with index {placeholder} cannot be instantiated using only {args_len} arguments")]
10	/// Missing argument value
11	ArgMissing {
12		/// The index of the missing argument.
13		placeholder: usize,
14		/// The number of arguments provided.
15		args_len: usize,
16	},
17	#[error("placeholder in position that expects type {placeholder_ty}, but got argument of type {arg_ty}")]
18	/// Invalid type for argument
19	InvalidType {
20		/// Type deduced by the position of the placeholder.
21		placeholder_ty: &'static str,
22		/// Type of the argument expression provided.
23		arg_ty: &'static str,
24	},
25	/// Unexpected number of expressions
26	#[error(
27		"unrolling expression evaluated to {args_len} expressions, but expected {expected_len}"
28	)]
29	UnexpectedLength {
30		/// The expected number of expressions
31		expected_len: usize,
32		/// The number of expressions that unrolling evaluated to.
33		args_len: usize,
34	},
35	/// Unexpected number of indexes in array access
36	#[error("array access with {args_len} indexes, but expected {expected_len} indexes")]
37	UnexpectedIndexes {
38		/// The expected number of indexing operations
39		expected_len: usize,
40		/// The number of indexing operations found.
41		args_len: usize,
42	},
43	/// Unknown identifier
44	#[error("unknown identifier {0}")]
45	UnknownIdentifier(String),
46}