-
Notifications
You must be signed in to change notification settings - Fork 3
Raise error if Help Scout returns validation errors #1
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
Conversation
lib/help_scout.rb
Outdated
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.
You can also define this inside the HelpScout class, I think I've seen it be done like that more often.
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.
Ah thought that was only possible inside a Module, but seems to be working 👍
bittersweet
left a comment
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.
Looks good, great improvement. There are some stylistic comments you might want to take a look at implementing.
lib/help_scout.rb
Outdated
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.
I think it would be nice for readability to extract these status codes into constants, I always forget what they are, or at least I have to think a bit for non 200/403/404 etc.
lib/help_scout.rb
Outdated
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.
What about raising a catch all type thing here at the end if the response is not one of 201 or 400? I'm not super sure what kind of statuses they return at the moment though.
lib/help_scout.rb
Outdated
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.
I think we normally do raise ErrorClass.new(message) but fine either way.
331fb38 to
ce6c17a
Compare
|
🚢 |
We sometimes send borked data to Help Scout, leading to validation errors on their side. They return these nicely, unfortunately the gem currently assumes success (such an optimist) and gives a non descriptive:
Because of a missing
locationheader. This adds a check on the status code of the response and raises aHelpScout::ValidationErrorexception with the actual error message returned from HS.