google-ads-php icon indicating copy to clipboard operation
google-ads-php copied to clipboard

HandleKeywordPolicyViolations not getting the right exception

Open SeriousJ55 opened this issue 1 year ago • 4 comments

The code in examples/ErrorHandling/HandleKeywordPolicyViolations.php doesn't work because policy violations of a keyword are thrown as ApiExceptions and not as GoogleAdsExceptions.

For instance, here are the first lines an error received for a policy violation:

object(Google\ApiCore\ApiException)#28230 (11) { ["message":protected]=> string(3883) "{ "message": "Request contains an invalid argument.", "code": 3, "status": "INVALID_ARGUMENT", "details": [ { "@type": "type.googleapis.com/google.ads.googleads.v15.errors.GoogleAdsFailure", "errors": [ { "errorCode": { "policyViolationError": "POLICY_ERROR" }, "message": "A policy was violated. See PolicyViolationDetails for more detail.", "trigger": { "stringValue": "Atestado para Comprovar Rela\u00e7\u00e3o de Prestador de Servi\u00e7os" }, "location": { "fieldPathElements": [ { "fieldName": "operations", "index": 0 }, { "fieldName": "create" }, { "fieldName": "keyword" }, { "fieldName": "text" } ] }, "details": { "policyViolationDetails": { "externalPolicyDescription": [...]

As you can see, this is an ApiException. So I can't access the associated policyViolationDetailsKey and thus can't ask for an exemption.

What am I missing?

SeriousJ55 avatar Apr 24 '24 16:04 SeriousJ55

There might be some changes recently that we aren't aware of. Let me look into this and will update this thread when I have more clues.

fiboknacky avatar Apr 24 '24 16:04 fiboknacky

Did you use REST, not gRPC?

fiboknacky avatar Jun 04 '24 15:06 fiboknacky

Yes, I use REST

Envoyé à partir de Outlook pour iOShttps://aka.ms/o0ukef


De : Thanet Knack Praneenararat @.> Envoyé : Tuesday, June 4, 2024 5:32:35 PM À : googleads/google-ads-php @.> Cc : SeriousJ55 @.>; Author @.> Objet : Re: [googleads/google-ads-php] HandleKeywordPolicyViolations not getting the right exception (Issue #1012)

Did you use REST, not gRPC?

— Reply to this email directly, view it on GitHubhttps://github.com/googleads/google-ads-php/issues/1012#issuecomment-2147832661, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGNJVK6ONZ7HALWYEK3HVO3ZFXMZHAVCNFSM6AAAAABGXG4KXWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNBXHAZTENRWGE. You are receiving this because you authored the thread.Message ID: @.***>

SeriousJ55 avatar Jun 04 '24 20:06 SeriousJ55

Ah. OK. REST cannot handle errors as well as gRPC right now. We have this in our feature request list, but it's going to take some time to finish it.

fiboknacky avatar Jun 05 '24 11:06 fiboknacky