Skip to content

Conversation

@felixarntz
Copy link
Member

Some provider API endpoints, such as those from Google may return an array of error objects with message inside. This PR enhances the ErrorMessageExtractor to account for that shape, leading to more helpful error messages.

Additionally, I noticed there's both a Providers\Http\Util namespace and a Providers\Http\Utilities namespace. That doesn't make any sense, so they are being combined into one as part of this PR.

@felixarntz felixarntz added this to the 0.4.0 milestone Dec 8, 2025
@felixarntz felixarntz added the [Type] Enhancement A suggestion for improvement. label Dec 8, 2025
@github-actions
Copy link

github-actions bot commented Dec 8, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: felixarntz <flixos90@git.wordpress.org>
Co-authored-by: JasonTheAdams <jason_the_adams@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link
Member

@JasonTheAdams JasonTheAdams left a comment

Choose a reason for hiding this comment

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

Small suggestion, but otherwise looks good!

Comment on lines +38 to +45
if (
isset($data[0]) &&
is_array($data[0]) &&
isset($data[0]['error']) &&
is_array($data[0]['error']) &&
isset($data[0]['error']['message']) &&
is_string($data[0]['error']['message'])
) {
Copy link
Member

Choose a reason for hiding this comment

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

You don't need to check each layer. PHP supports checking multiple layers down. 👍

Suggested change
if (
isset($data[0]) &&
is_array($data[0]) &&
isset($data[0]['error']) &&
is_array($data[0]['error']) &&
isset($data[0]['error']['message']) &&
is_string($data[0]['error']['message'])
) {
if (isset($data[0]['error']['message']) && is_string($data[0]['error']['message'])) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants