Skip to content

Make status code and NGINX error codes on internalError publicly accessible #489

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 28, 2025

Conversation

arussellf5
Copy link
Contributor

Proposed changes

This will allow users of the plus client to check errors and decide what further action to take. This fix follows the advice of commentators who counsel users of go to assert errors for behavior, not type. https://dave.cheney.net/2014/12/24/inspecting-errors The user would create a simple error interface including Status() and Code() methods and then could use errors.As() to cast the internalError to their own interface type. For example, if the user attempts to delete an upstream server using the client, the user can check the error returned for a http.StatusNotFound code, and if present, can make their application take no further action. If some error status code is returned, then the user can retry the delete. Previously in order to perform this kind of analysis the user would have to resort to string checking on the error: never a good solution.

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that all unit tests pass after adding my changes
  • I have updated necessary documentation
  • I have rebased my branch onto main
  • I will ensure my PR is targeting the main branch and pulling from my branch from my own fork

@arussellf5 arussellf5 requested a review from a team as a code owner March 25, 2025 22:35
Copy link

nginx-bot bot commented Mar 25, 2025

Hi @arussellf5!

Thanks for opening this pull request!
Be sure to check out our Contributing Guidelines while you wait for someone on the team to review this.

@nginx-bot nginx-bot bot added the community Issues or PRs opened by an external contributor label Mar 25, 2025
@arussellf5 arussellf5 force-pushed the main branch 2 times, most recently from e8978eb to d169934 Compare March 26, 2025 15:14
…ssible

This will allow users of the plus client to check errors and decide what further action to take. This fix follows the advice of commentators who counsel users of go to assert errors for behavior, not type. https://dave.cheney.net/2014/12/24/inspecting-errors The user would create a simple error interface including Status() and Code() methods and then could use errors.As() to cast the internalError to their own interface type. For example, if the user attempts to delete an upstream server using the client, the user can check the error returned for a http.StatusNotFound code, and if present, can make their application take no further action. If some error status code is returned, then the user can retry the delete. Previously in order to perform this kind of analysis the user would have to resort to string checking on the error: never a good solution.
@mpstefan mpstefan mentioned this pull request Mar 26, 2025
@mpstefan mpstefan added this to the v2.4.0 milestone Mar 26, 2025
@jjngx jjngx merged commit 6e94c53 into nginx:main Mar 28, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Issues or PRs opened by an external contributor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants