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
//! Error types for the rtemis-a3 library.
//!
//! All fallible operations return `Result<T, A3Error>`. The two variants
//! map onto the two failure modes described in the A3 spec:
//!
//! - [`A3Error::Parse`] — the input was not valid JSON
//! - [`A3Error::Serialize`] — a valid A3 value could not be serialized to JSON
//! - [`A3Error::Validate`] — the JSON parsed but violated A3 rules
// `thiserror::Error` is a derive macro that generates the boilerplate needed
// to make our enum implement the standard `std::error::Error` trait.
use Error;
/// The single error type returned by every fallible function in this crate.
///
/// In Rust, errors are values — there are no exceptions. Every function that
/// can fail returns `Result<T, A3Error>`, which is either `Ok(value)` or
/// `Err(A3Error::...)`. The caller decides how to handle it.
///
/// `#[derive(Debug)]` lets you print the error with `{:?}` formatting.
/// `#[derive(Error)]` (from thiserror) implements `std::error::Error` for us.