Skip to content

Commit 2cf20a7

Browse files
committed
Separate out SQLite disk errors
Use different error type strings for DB corruption and disk full. This way we can track these errors differently in Sentry.
1 parent 9877328 commit 2cf20a7

File tree

2 files changed

+46
-16
lines changed

2 files changed

+46
-16
lines changed

components/logins/src/error.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,24 @@ impl GetErrorHandling for Error {
181181
})
182182
.report_error("logins-sync"),
183183
},
184+
Error::SqlError(rusqlite::Error::SqliteFailure(err, _)) => match err.code {
185+
rusqlite::ErrorCode::DatabaseCorrupt => {
186+
ErrorHandling::convert(LoginsApiError::UnexpectedLoginsApiError {
187+
reason: self.to_string(),
188+
})
189+
.report_error("logins-db-corrupt")
190+
}
191+
rusqlite::ErrorCode::DiskFull => {
192+
ErrorHandling::convert(LoginsApiError::UnexpectedLoginsApiError {
193+
reason: self.to_string(),
194+
})
195+
.report_error("logins-db-disk-full")
196+
}
197+
_ => ErrorHandling::convert(LoginsApiError::UnexpectedLoginsApiError {
198+
reason: self.to_string(),
199+
})
200+
.report_error("logins-unexpected"),
201+
},
184202
// Unexpected errors that we report to Sentry. We should watch the reports for these
185203
// and do one or more of these things if we see them:
186204
// - Fix the underlying issue

components/places/src/error.rs

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -216,24 +216,36 @@ impl GetErrorHandling for Error {
216216
})
217217
.log_warning()
218218
}
219-
// Can't pattern match on `err` without adding a dep on the sqlite3-sys crate,
220-
// so we just use a `if` guard.
221-
Error::SqlError(rusqlite::Error::SqliteFailure(err, _))
222-
if err.code == rusqlite::ErrorCode::DatabaseBusy =>
223-
{
224-
ErrorHandling::convert(PlacesApiError::PlacesConnectionBusy {
225-
reason: self.to_string(),
226-
})
227-
.log_warning()
228-
}
229-
Error::SqlError(rusqlite::Error::SqliteFailure(err, _))
230-
if err.code == rusqlite::ErrorCode::OperationInterrupted =>
231-
{
232-
ErrorHandling::convert(PlacesApiError::OperationInterrupted {
219+
Error::SqlError(rusqlite::Error::SqliteFailure(err, _)) => match err.code {
220+
rusqlite::ErrorCode::DatabaseBusy => {
221+
ErrorHandling::convert(PlacesApiError::PlacesConnectionBusy {
222+
reason: self.to_string(),
223+
})
224+
.log_warning()
225+
}
226+
rusqlite::ErrorCode::OperationInterrupted => {
227+
ErrorHandling::convert(PlacesApiError::OperationInterrupted {
228+
reason: self.to_string(),
229+
})
230+
.log_info()
231+
}
232+
rusqlite::ErrorCode::DatabaseCorrupt => {
233+
ErrorHandling::convert(PlacesApiError::UnexpectedPlacesException {
234+
reason: self.to_string(),
235+
})
236+
.report_error("places-db-corrupt")
237+
}
238+
rusqlite::ErrorCode::DiskFull => {
239+
ErrorHandling::convert(PlacesApiError::UnexpectedPlacesException {
240+
reason: self.to_string(),
241+
})
242+
.report_error("places-db-disk-full")
243+
}
244+
_ => ErrorHandling::convert(PlacesApiError::UnexpectedPlacesException {
233245
reason: self.to_string(),
234246
})
235-
.log_info()
236-
}
247+
.report_error("places-unexpected"),
248+
},
237249
Error::InterruptedError(err) => {
238250
// Can't unify with the above ... :(
239251
ErrorHandling::convert(PlacesApiError::OperationInterrupted {

0 commit comments

Comments
 (0)