-
Notifications
You must be signed in to change notification settings - Fork 7
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
Catch when patron_hash is TrueClass #4647
Conversation
app/models/requests/patron.rb
Outdated
@@ -94,7 +94,10 @@ def to_h | |||
|
|||
def load_patron(user:) | |||
patron_hash = current_patron_hash(user.uid) | |||
errors << "A problem occurred looking up your library account." if patron_hash.blank? | |||
if patron_hash.instance_of?(TrueClass) || patron_hash.blank? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me, it would make more sense if we caught this error lower down in the stack trace, and make sure that this method doesn't get a patron_hash that's an instance of TrueClass.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
This reverts commit e6f8fa0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @rladdusaw -- I agree with @maxkadel that we should catch this at a lower level if possible. I think it would be beneficial for two reasons:
- Hopefully we could avoid having a type check, and
- TrueClass gives the vibes of something happened successfully -- at least to me-- so I find it counterintuitive here that it actually means that getting the hash errored. It would be nice if we could avoid that.
app/models/requests/patron.rb
Outdated
@@ -94,7 +94,10 @@ def to_h | |||
|
|||
def load_patron(user:) | |||
patron_hash = current_patron_hash(user.uid) | |||
errors << "A problem occurred looking up your library account." if patron_hash.blank? | |||
if patron_hash.instance_of?(TrueClass) || patron_hash.blank? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
Co-authored-by: Max Kadel <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @rladdusaw and @maxkadel ! 🐈⬛ 🦄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @rladdusaw!
Resolves #4581