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

Exception Hints #302

Merged
merged 3 commits into from
Nov 4, 2020
Merged

Exception Hints #302

merged 3 commits into from
Nov 4, 2020

Conversation

afeld
Copy link
Contributor

@afeld afeld commented Apr 5, 2015

I work with a lot of people who are new to coding, and have found that people often get tripped up with reading Ruby exceptions. For example:

user = User.where(...).first
user # => nil
user.save # NoMethodError: undefined method `save' for nil:NilClass

While precise, error messages like this don't do a very good job of guiding the reader to how to fix the problems. This PR is a proof-of-concept giving better_errors users a bit of help.

screen shot 2015-04-05 at 3 15 34 am

Feedback welcome! In particular, what edge cases am I missing?

P.S. Ideally the message above would read

Hint: user is nil when it probably shouldn't be.

but that requires some fancy AST parsing (I think).

P.P.S. If others agree it would be useful, I think a good medium-term goal would be to move the backtrace cleaning and hint logic to an external gem, where it could be leveraged by non-web things (like Exercism) that can't use better_errors.

@afeld
Copy link
Contributor Author

afeld commented Jul 17, 2015

Bump!

@jasonnoble
Copy link

❤️ ❤️ ❤️

@RobinDaugherty RobinDaugherty added this to the v2.7 milestone Feb 27, 2020
@RobinDaugherty RobinDaugherty modified the milestones: v2.7, v2.8 Apr 24, 2020
@RobinDaugherty RobinDaugherty modified the milestones: v2.8, v2.9 Sep 15, 2020
RobinDaugherty added a commit that referenced this pull request Nov 4, 2020
@RobinDaugherty RobinDaugherty merged commit d010b26 into BetterErrors:master Nov 4, 2020
@RobinDaugherty RobinDaugherty changed the title add exception hints Exception hints Nov 4, 2020
@RobinDaugherty RobinDaugherty changed the title Exception hints Exception Hints Nov 4, 2020
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.

3 participants