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

Better error handling during checkout #814

Open
aayla-secura opened this issue Nov 1, 2024 · 0 comments
Open

Better error handling during checkout #814

aayla-secura opened this issue Nov 1, 2024 · 0 comments

Comments

@aayla-secura
Copy link

This is probably never gonna reach the top of your list, but here you go. I discovered while trying to unit test an addon I'm writing for GetPaid, that it's very hard to unit test the checkout ajax callback. The reason is that the Wordpress unit test case for testing Ajax calls, quite sensibly and correctly prevents the script from dying when wp_send_json_* is called by registering a custom die handler that throws an exception instead, and is meant to be caught by the test case. However GetPaid's checkout process catches the base Exception class, which makes it impossible for a custom die handler to gracefully stop the ajax action without killing the script.

Given that you already have a custom GetPaid_Payment_Exception used in places, I suggest you change all other places that throw the base Exception class to throw GetPaid_Payment_Exception instead and only catch GetPaid_Payment_Exception and not other Exceptions. This is also good practice I believe, since unexpected exceptions that may result from other code shouldn't be caught by you.

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

No branches or pull requests

1 participant