Add recaptcha_failure_reason for enchanced error reporting #459
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This update introduces the
recaptcha_failure_reason
method to provide developers with detailed information on common verification failures. This enhancement aims to improve debugging and error handling when integrating to applications.I had annoying moments debugging errors when using the gem. Gem itself worked nicely but the error messages needed some manual work. E.g. when custom javascripts set the request parameter correctly but with wrong name, the gem didn't give any errors it just failed. I wanted to have simpler error messages. This also helps when logging the results as now I have single method to return some information.
Key Changes:
recaptcha_failure_reason
method incontroller_methods.rb
to return detailed failure reasons.verify_recaptcha
method to set@_recaptcha_failure_reason
with specific error messages based on the verification outcome.verify_recaptcha!
to raiseVerifyError
with an informative error message.test/verify_test.rb
to cover new failure scenarios and ensurerecaptcha_failure_reason
provides accurate information.Pre-Merge Checklist