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

add api wrapper with retries (WP-669) #355

Merged
merged 3 commits into from
Jan 4, 2022
Merged

Conversation

vsolovei-smartling
Copy link
Contributor

No description provided.

Comment on lines +693 to +696
private function formatError(\Exception $e): string
{
return $e instanceof SmartlingApiException ? $e->formatErrors() : $e->getMessage();
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Extracted helper function since \Exception doesn't have formatErrors()

use Smartling\Vendor\Jralph\Retry\Retry;
use Smartling\Vendor\Jralph\Retry\RetryException;

class ApiWrapperWithRetries implements ApiWrapperInterface {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I already left this comment: why not use PHP magic methods instead of implement dumb proxy for each method

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm a strong opponent of magic methods, but I've tried experimenting with them for this task. I've found no magic methods that are applicable, so created another wrapper level

@vsolovei-smartling vsolovei-smartling merged commit 755936f into master Jan 4, 2022
@vsolovei-smartling vsolovei-smartling deleted the WP-669-api-retries branch January 4, 2022 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants