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

Catch when patron_hash is TrueClass #4647

Merged
merged 10 commits into from
Dec 18, 2024
Merged

Conversation

rladdusaw
Copy link
Contributor

Resolves #4581

@coveralls
Copy link

coveralls commented Dec 16, 2024

Coverage Status

coverage: 96.415%. remained the same
when pulling 0069df9 on 4581-handle-patron-errors
into abddb2b on main.

@@ -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?
Copy link
Contributor

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.

Copy link
Member

Choose a reason for hiding this comment

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

+1

Copy link
Member

@sandbergja sandbergja left a 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.

@@ -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?
Copy link
Member

Choose a reason for hiding this comment

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

+1

Copy link
Member

@sandbergja sandbergja left a 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 ! 🐈‍⬛ 🦄

@sandbergja sandbergja merged commit c6d2549 into main Dec 18, 2024
14 checks passed
@sandbergja sandbergja deleted the 4581-handle-patron-errors branch December 18, 2024 20:48
Copy link
Contributor

@maxkadel maxkadel left a comment

Choose a reason for hiding this comment

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

Thanks @rladdusaw!

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.

In Requests, handle errors from Bibdata gracefully when building patron
4 participants