Skip to content

Update error handling to use body message instead of reason phrase #110

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Manisha15
Copy link
Contributor

Fixes #108

@Manisha15 Manisha15 force-pushed the fix_error_handling branch from 625d8b9 to 89dd5b5 Compare July 28, 2025 07:19
raise(Fog::Errors::NotFound)
end
rescue StandardError
raise e
Copy link
Contributor

Choose a reason for hiding this comment

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

whats the reason to to just re-raise an exception? is the exception handling then useful?

@@ -53,10 +53,16 @@ def get(id)
status_data = service.get_server_status path_params
config_data = service.get_server_config path_params
rescue StandardError => e
if e.respond_to?('response') && e.response.respond_to?('data') && e.response.data.has_key?(:reason_phrase) && e.response.data[:reason_phrase].end_with?('does not exist')
raise(Fog::Errors::NotFound)
if e.respond_to?('response') && e.response.respond_to?('data') && e.response.data.has_key?(:body)
Copy link
Contributor

Choose a reason for hiding this comment

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

handling body additionally, might be useful - but we still should catch the reason_pharse, too?

Copy link

Choose a reason for hiding this comment

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

As I explained in #108, the reason phrase should not be used for anything. It might be overwritten by intermediate servers or completely discarded.

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.

Avoid relying on HTTP reason-phrase for error handling (RFC 9112 compliance)
3 participants