How to catch Errors.

24 views
Skip to first unread message

John Geliberte

unread,
Sep 15, 2015, 3:04:57 AM9/15/15
to AdWords API Forum
Hi guys, Good day!

I would like to ask if how can i handle an error gracefully. i'm planning to catch an CustomerSyncError.INVALID_CAMPAIGN_ID @ selector as a workaround to my problem.
Im using java by the way. thanks in advance.

Good day.

Umesh Dengale

unread,
Sep 15, 2015, 7:38:57 PM9/15/15
to AdWords API Forum
Hello,

You could use below Java example code to handle the CustomerSyncError.INVALID_CAMPAIGN_ID error gracefully.
try{
     accountChanges = customerSyncService.get(customerSyncSelector);
    }catch (ApiException e) {
       for (ApiError error : e.getErrors()) {
         if (error instanceof CustomerSyncError &&  ((CustomerSyncError) error).getReason().equals(CustomerSyncErrorReason.INVALID_CAMPAIGN_ID)) {
          CustomerSyncError customerSyncError = (CustomerSyncError) error;
            //System.out.println("Catching CustomerSyncError.INVALID_CAMPAIGN_ID");
                          
         }
       }
    }
    
Cheers,
Umesh, AdWords API Team.
Reply all
Reply to author
Forward
0 new messages