Skip to content

Commit

Permalink
fix: don't skip DbError in the ReportableError chain (#649)
Browse files Browse the repository at this point in the history
Issue: SYNC-4172
  • Loading branch information
pjenvey authored Mar 7, 2024
1 parent fb2b0ee commit c9b97d1
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion autoendpoint/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ impl ReportableError for ApiError {
fn reportable_source(&self) -> Option<&(dyn ReportableError + 'static)> {
match &self.kind {
ApiErrorKind::EndpointUrl(e) => Some(e),
ApiErrorKind::Database(e) => e.reportable_source(),
ApiErrorKind::Database(e) => Some(e),
_ => None,
}
}
Expand Down Expand Up @@ -387,3 +387,21 @@ fn errno_from_validation_errors(e: &ValidationErrors) -> Option<usize> {
})
.next()
}

#[cfg(test)]
mod tests {
use autopush_common::{db::error::DbError, sentry::event_from_error};

use super::{ApiError, ApiErrorKind};

#[test]
fn sentry_event_with_extras() {
let dbe = DbError::Integrity("foo".to_owned(), Some("bar".to_owned()));
let e: ApiError = ApiErrorKind::Database(dbe).into();
let event = event_from_error(&e);
assert_eq!(event.exception.len(), 2);
assert_eq!(event.exception[0].ty, "Integrity");
assert_eq!(event.exception[1].ty, "ApiError");
assert_eq!(event.extra.get("row"), Some(&"bar".into()));
}
}

0 comments on commit c9b97d1

Please sign in to comment.