Skip to content

Conversation

@alukach
Copy link
Contributor

@alukach alukach commented May 13, 2025

Related Issue(s): #

Proposed Changes:

In #58, we introduced thiserror. When the API is overrun, we are now serving 500 rather than 404 responses (which seems more accurate to our needs) but our logs are missing important contextual information as they appear to be from the legacy APIError logs which lacked some information.

This PR:

  1. continues to convert the remainder of our codebase to make use of our new error/logging pattern
  2. flattens out the match statements, as we can now throw our BackendError and have it automatically converted to a response via the actix_web::error::ResponseError trait, as demonstrated in the Actix guide: https://actix.rs/docs/errors#an-example-of-a-custom-error-response

PR Checklist:

  • This PR is made against the dev branch (all proposed changes except releases should be against dev, not main).
  • This PR has no breaking changes.
  • This PR contains only one commit.
  • I have updated or added new tests to cover the changes in this PR.
  • All tests are passing.
  • This PR affects the Source Cooperative Frontend & API,
    and I have opened issue/PR #XXX to track the change.

@alukach alukach requested a review from jedsundwall May 13, 2025 15:05
jedsundwall
jedsundwall previously approved these changes May 13, 2025
Copy link

@jedsundwall jedsundwall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm really not qualified to give this a proper review but I'm glad you're doing this.

@alukach alukach merged commit 562c2de into dev May 13, 2025
@alukach alukach deleted the observability/convert-error-handling branch May 13, 2025 15:22
Comment on lines +179 to +183
impl From<serde_xml_rs::Error> for BackendError {
fn from(error: serde_xml_rs::Error) -> BackendError {
BackendError::XmlParseError(format!("failed to parse xml: {}", error))
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one we could have used thiserror's #[from] macro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants