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

raising ArgumentError if exposure_options[:using] does not respond to represent #99

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

themusicman
Copy link

The current NoMethodError that gets raised requires time to trace and debug. The ArgumentError that is raised now gives a little more information and context to fix the issue quicker.

@dblock
Copy link
Member

dblock commented Nov 21, 2014

I like it. Can you please fix the build (RuboCop) and update CHANGELOG?

@themusicman
Copy link
Author

Updated the CHANGELOG.md and build is green.

exposure_options[:using] = exposure_options[:using].constantize if exposure_options[:using].respond_to? :constantize

unless exposure_options[:using].respond_to? :represent
raise ArgumentError, "The value you pass as the using option must respond to represent. It should be a class that inherits from Grape::Entity. [#{exposure_options[:using].inspect}]"
Copy link
Member

Choose a reason for hiding this comment

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

Just re-read this. It doesn't have to be a class that inherits Grape::Entity, that is just one possible class. I think it should say something like "#{exposure_options[:using].class} must implement represent.", what do you think?

@dblock
Copy link
Member

dblock commented Nov 23, 2014

See my comment on the contents of the exception. Also can you squash these commits? Thanks.

@dblock
Copy link
Member

dblock commented Apr 13, 2015

Bump.

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