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

Improve error handling #12

Open
rvdsteege opened this issue Nov 1, 2024 · 0 comments
Open

Improve error handling #12

rvdsteege opened this issue Nov 1, 2024 · 0 comments

Comments

@rvdsteege
Copy link
Member

In internal Help Scout ticket https://secure.helpscout.net/conversation/2751009728/27927 a user informed about an unclear error message:

Unknown response from Pay.nl error.

It appears the given API token is invalid and this results in a HTTP 401 Unauthorized with an empty response body. We could improve the error message a bit for these cases.

// Body.
$body = wp_remote_retrieve_body( $response );
$result = json_decode( $body );
// Result is array.
if ( is_array( $result ) ) {
return $result;
}
// Result is object
// NULL is returned if the json cannot be decoded or if the encoded data is deeper than the recursion limit.
if ( ! is_object( $result ) ) {
throw new \Exception( __( 'Unknown response from Pay.nl error.', 'pronamic_ideal' ) );
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

No branches or pull requests

1 participant