Skip to content

Propagate Reporter Errors#243

Draft
Robin5605 wants to merge 2 commits intomainfrom
robin/patch/propagate-reporter-errors
Draft

Propagate Reporter Errors#243
Robin5605 wants to merge 2 commits intomainfrom
robin/patch/propagate-reporter-errors

Conversation

@Robin5605
Copy link
Member

Contains changes from #228 + tests

Also make a dependency and use FastAPI dependency injection to accept
the httpx.Client instance. This also makes it much easier to test.
@Robin5605 Robin5605 requested review from a team as code owners April 6, 2024 06:45
detail = "Dragonfly Reporter service failed"
log.error(detail, status=err.response.status_code, message=err.response.text)
raise HTTPException(502, detail=detail)

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

Comment on lines +223 to +225
try:
response.raise_for_status()
except httpx.HTTPStatusError as err:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
try:
response.raise_for_status()
except httpx.HTTPStatusError as err:
if not response.is_success:

)

httpx.post(f"{mainframe_settings.reporter_url}/report/{name}", json=jsonable_encoder(report))
http_client.post(f"{mainframe_settings.reporter_url}/report/{name}", json=jsonable_encoder(report))
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't we want to check for success here also?

response = http_client.post(f"{mainframe_settings.reporter_url}/report/email", json=jsonable_encoder(report))
try:
response.raise_for_status()
except httpx.HTTPStatusError as err:
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's extract the logic for error checking and sending the request to a new function so it's easier to test.

@shenanigansd shenanigansd marked this pull request as draft May 30, 2024 01:09
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.

2 participants