1pub type Result<T, E = Error> = std::result::Result<T, E>;
5
6#[derive(Clone, PartialEq, Eq, Debug, thiserror::Error)]
8#[non_exhaustive]
9pub enum Error {
10 #[error("{prim}: {message}")]
12 Type {
13 prim: &'static str,
15 message: String,
17 },
18 #[error("{prim}: unsupported: {message}")]
20 Unsupported {
21 prim: &'static str,
23 message: String,
25 },
26 #[error("malformed IR: {0}")]
28 Malformed(String),
29}
30
31impl Error {
32 pub fn type_error(prim: &'static str, message: impl Into<String>) -> Self {
34 Self::Type {
35 prim,
36 message: message.into(),
37 }
38 }
39
40 pub fn unsupported(prim: &'static str, message: impl Into<String>) -> Self {
42 Self::Unsupported {
43 prim,
44 message: message.into(),
45 }
46 }
47}