Skip to content
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

Set the failed http response in a custom attribute instead of cause #173

Merged

Conversation

harmonymjb
Copy link
Contributor

#cause in a custom error should return the expected class. This commit updates the custom value that is useful to store, the response, to use a specific name rather than overriding #cause’s behavior.

Ruby documentation explains that the default expectation of #cause is that it will return either an_exception or nil. By setting an HTTP::Response to return from #cause, tools utilizing it may expect to send messages that may fail.

https://ruby-doc.org/3.2.6/Exception.html#method-i-cause

Specifically, I experienced a NoMethodError: undefined method 'backtrace' when an error occurred within pry.

image

`#cause` in a custom error should return the expected class. This
commit updates the custom value that is useful to store, the response,
to use a specific name rather than overriding `#cause`’s behavior.

Ruby documentation explains that the default expectation of #cause is
that it will return either `an_exception` or `nil`. By setting an
`HTTP::Response` to return from `#cause`, tools utilizing it may expect
to send messages that may fail.

https://ruby-doc.org/3.2.6/Exception.html#method-i-cause

Specifically, I experienced a `NoMethodError: undefined method
'backtrace'` when an error occurred within `pry`.
@hakanensari hakanensari merged commit 0d2578c into lineofflight:main Nov 4, 2024
3 of 5 checks passed
@hakanensari
Copy link
Member

Good point—merging now. Thanks!

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