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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
use crate::storage::bookmarks::BookmarkRootGuid;
use crate::types::BookmarkType;
use interrupt_support::Interrupted;
use serde_json::Value as JsonValue;
#[derive(Debug, thiserror::Error)]
pub enum ErrorKind {
#[error("Invalid place info: {0}")]
InvalidPlaceInfo(InvalidPlaceInfo),
#[error("The store is corrupt: {0}")]
Corruption(Corruption),
#[error("Error synchronizing: {0}")]
SyncAdapterError(#[from] sync15::Error),
#[error("Error merging: {0}")]
MergeError(#[from] dogear::Error),
#[error("Error parsing JSON data: {0}")]
JsonError(#[from] serde_json::Error),
#[error("Error executing SQL: {0}")]
SqlError(#[from] rusqlite::Error),
#[error("Error parsing URL: {0}")]
UrlParseError(#[from] url::ParseError),
#[error("A connection of this type is already open")]
ConnectionAlreadyOpen,
#[error("An invalid connection type was specified")]
InvalidConnectionType,
#[error("IO error: {0}")]
IoError(#[from] std::io::Error),
#[error("Operation interrupted")]
InterruptedError(#[from] Interrupted),
#[error("Tried to close connection on wrong PlacesApi instance")]
WrongApiForClose,
#[error("Incoming bookmark missing type")]
MissingBookmarkKind,
#[error("Incoming bookmark has unsupported type {0}")]
UnsupportedIncomingBookmarkType(JsonValue),
#[error("Synced bookmark has unsupported kind {0}")]
UnsupportedSyncedBookmarkKind(u8),
#[error("Synced bookmark has unsupported validity {0}")]
UnsupportedSyncedBookmarkValidity(u8),
#[error("Illegal database path: {0:?}")]
IllegalDatabasePath(std::path::PathBuf),
#[error("Protobuf decode error: {0}")]
ProtobufDecodeError(#[from] prost::DecodeError),
#[error("UTF8 Error: {0}")]
Utf8Error(#[from] std::str::Utf8Error),
#[error("Database cannot be upgraded")]
DatabaseUpgradeError,
#[error("Database version {0} is not supported")]
UnsupportedDatabaseVersion(i64),
}
error_support::define_error! {
ErrorKind {
(SyncAdapterError, sync15::Error),
(JsonError, serde_json::Error),
(UrlParseError, url::ParseError),
(SqlError, rusqlite::Error),
(InvalidPlaceInfo, InvalidPlaceInfo),
(Corruption, Corruption),
(IoError, std::io::Error),
(MergeError, dogear::Error),
(ProtobufDecodeError, prost::DecodeError),
(InterruptedError, Interrupted),
(Utf8Error, std::str::Utf8Error),
}
}
#[derive(Debug, thiserror::Error)]
pub enum InvalidPlaceInfo {
#[error("No url specified")]
NoUrl,
#[error("Invalid guid")]
InvalidGuid,
#[error("Invalid parent: {0}")]
InvalidParent(String),
#[error("Invalid child guid")]
InvalidChildGuid,
#[error("No such item: {0}")]
NoSuchGuid(String),
#[error("No such url")]
NoSuchUrl,
#[error("Can't update a bookmark of type {0} with one of type {1}")]
MismatchedBookmarkType(u8, u8),
#[error("URL too long")]
UrlTooLong,
#[error("The tag value is invalid")]
InvalidTag,
#[error("Cannot change the '{0}' property of a bookmark of type {1:?}")]
IllegalChange(&'static str, BookmarkType),
#[error("Cannot update the bookmark root {0:?}")]
CannotUpdateRoot(BookmarkRootGuid),
}
#[derive(Debug, thiserror::Error)]
pub enum Corruption {
#[error("Bookmark '{0}' has a parent of '{1}' which does not exist")]
NoParent(String, String),
#[error("The local roots are invalid")]
InvalidLocalRoots,
#[error("The synced roots are invalid")]
InvalidSyncedRoots,
#[error("Bookmark '{0}' has no parent but is not the bookmarks root")]
NonRootWithoutParent(String),
}