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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//! Defines the result and error types for this crate.
/// A generic result type.
pub type Result<T> = std::result::Result<T, Error>;
/// An enum representing all possible library errors.
#[derive(Debug, thiserror::Error)]
pub enum Error {
/// Error returned when the default Apple Books database cannot be found.
#[error("missing default Apple Books databases")]
MissingDefaultDatabase,
/// Error returned when there are issues connecting to a database.
#[error("unable to connect to '{name}*.sqlite' at {path}")]
DatabaseConnection {
/// The basename of the database: `BKLibrary` or `AEAnnotation`.
name: String,
/// The path to the database.
path: String,
},
/// Error returned when the currently installed version of Apple Books for macOS is unsupported.
///
/// This most likely means that the database schema is different than the one the query has been
/// designed for. In that case, the currently installed version of Apple Books is considered
/// unsupported.
#[error("unsupported version of Apple Books for macOS: {version}")]
UnsupportedMacosVersion {
/// The currently installed Apple Books for macOS version number.
version: String,
/// The source error string.
error: String,
},
/// Error returned when the currently installed version of Apple Books for iOS is unsupported.
///
/// This most likely means that the plist schema is different than the one used for
/// deserialization. In that case, the currently installed version of Apple Books for iOS is
/// considered unsupported.
// TODO: Is there a way to retrieve the iOS version from the device?
#[error("unsupported version of Apple Books for iOS: {error}")]
UnsupportedIosVersion {
/// The source error string.
error: String,
},
/// Error returned when a syntax error is detected in how a template's config block is defined.
/// This does not include YAML syntax error.
#[error("cannot read config for: {path}")]
InvalidTemplateConfig {
/// The partial path to the template e.g. `nested/template.md`.
path: String,
},
/// Error returned when a requested template-group does not exist.
#[error("no template-group named: '{name}'")]
NonexistentTemplateGroup {
/// The name of the template-group.
name: String,
},
/// Error returned if [`tera`][tera] encounters any errors.
///
/// [tera]: https://docs.rs/tera/latest/tera/
#[error(transparent)]
InvalidTemplate(#[from] tera::Error),
/// Error returned if [`serde_json`][serde-json] encounters any errors during serialization.
///
/// [serde-json]: https://docs.rs/serde_json/latest/serde_json/
#[error(transparent)]
JsonSerializationError(#[from] serde_json::Error),
/// Error returned if [`plist`][plist] encounters any errors during deserialization.
///
/// [plist]: https://docs.rs/plist/latest/plist/
#[error(transparent)]
PlistDeserializationError(#[from] plist::Error),
/// Error returned if [`serde_yaml`][serde-yaml] encounters any errors during deserialization.
///
/// [serde-yaml]: https://docs.rs/serde_yaml/latest/serde_yaml/
#[error(transparent)]
YamlDeserializationError(#[from] serde_yaml_ng::Error),
/// Error returned if any other IO errors are encountered.
#[error(transparent)]
IoError(#[from] std::io::Error),
}