Cannot catch ApiException

628 views
Skip to first unread message

Faisal Dgs

unread,
Dec 16, 2009, 3:02:53 PM12/16/09
to AdWords API Forum
Hi There,

I am using v200909. I am trying to catch ApiException in catch block
but I am getting "The type caught or thrown must be derived from
System.Exception" exception. I am using C# 3.5.

Please help. Because I have a sample code where ApiException is caught
in catch block at http://adwordsapi.blogspot.com/.

Regards,
Faisal

AdWords API Advisor

unread,
Dec 17, 2009, 12:46:33 PM12/17/09
to AdWords API Forum
Hi Faisal,

Are you using the AdWords API .NET client library? If so I would
suggest you open a bug on the issue tracker to alert the maintainers
of this problem:

http://code.google.com/p/google-api-adwords-dotnet/issues/list

Best,
- Eric Koleda, AdWords API Team

MarkoZ

unread,
Dec 18, 2009, 4:47:08 AM12/18/09
to AdWords API Forum
Hi,

That sample code is old. They have changed Exception handling.

ApiException is no Exception. AdWordsApiException is.

Here's some code snippet that you need to use:

try
{
// service call
adGroupCriterionService.mutate(operations.ToArray());
}
catch (AdWordsApiException ex)
{
// here is ApiException
ApiException apiEx = (ApiException)ex.ApiException;
}

Regards,
--
Josip
GemBox.Ppc - http://www.GemBoxSoftware.com/Ppc/Overview.htm - Advanced
AdWords API for .NET

Almas Kanjiyani

unread,
Dec 18, 2009, 1:34:59 AM12/18/09
to AdWords API Forum
Hi Eric,

I am also facing the same issue. While i try to catch the ApiException
in case of any AuthenticationError.GOOGLE_COOKIE_INVALID exception, it
throws a SoapException instead of an ApiException. Why is this so?

Also the ApiException class is not available on adding reference to
the v200909 APIs. Is there anything i am missing?

Thanks,
Almas

On Dec 17, 10:46 pm, AdWords API Advisor

> > Faisal- Hide quoted text -
>
> - Show quoted text -

AdWords API Advisor

unread,
Jan 11, 2010, 10:28:00 AM1/11/10
to AdWords API Forum
Hi Almas,

The ApiException class is not immediately available in .NET, and the
AdWords API .NET client library did some work to expose it. I would
recommend using the library as it takes care of this and other
difficulties.

Best,
- Eric

On Dec 18 2009, 1:34 am, Almas Kanjiyani <kanjiyanial...@gmail.com>
wrote:

Reply all
Reply to author
Forward
0 new messages