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

Include body.class feedback for non-String body error #756

Merged
merged 3 commits into from Dec 17, 2019
Merged

Include body.class feedback for non-String body error #756

merged 3 commits into from Dec 17, 2019

Conversation

aploshay
Copy link
Contributor

@aploshay aploshay commented Jun 6, 2019

A VCR::Request object performs this following initialization check:

        if body && !body.is_a?(String)
          raise ArgumentError, "#{self.class} initialized with an invalid body: #{body.inspect}."
        end

The error is raised for a non-String body, so it's helpful for the error message to return the actual body.class -- but body.inspect isn't a robust way to provide that, since some but not all objects include the class in their .inspect output. So this PR explicitly includes body.class output.

It also parenthetically mentions "(non-String)" after "invalid", to try to convey the issue is about the class check and not anything with the content of the body, itself.

Resolves #748

@olleolleolle olleolleolle merged commit 4fe5149 into vcr:master Dec 17, 2019
@aploshay aploshay deleted the revised_argument_error_message branch December 17, 2019 15: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.

Revise the ArgumentError message for VCR::Request initialized with a non-String body
3 participants