APIException

10 views
Skip to first unread message

AKa

unread,
Dec 3, 2008, 8:15:09 AM12/3/08
to AdWords API Forum
Hello,
can me anybody show a example how can I use APIException object from
AdWords API in .NET?

Regards
Anton Kalcik

AdWords API Advisor

unread,
Dec 3, 2008, 3:09:53 PM12/3/08
to AdWords API Forum
Hello Anton,

I'm not sure I understand your question. What are you trying to
accomplish?

Cheers,
-Jeff Posnick, AdWords API Team

Pete Lavetsky (AdWords API Guru)

unread,
Dec 3, 2008, 4:23:45 PM12/3/08
to AdWords API Forum
This is Java but should be very close:

try {
//Something
} catch( ApiException apiException ) {
log.error( "There was a problem: " + apiException.getMessage1() );
log.error( "The error code is " + apiException.getCode() );
if( apiException.getTrigger() != null )
log.error( "The trigger was " + apiException.getTrigger() );

if( apiException.getErrors() != null && apiException.getErrors
().length > 0 ) {
log.info( "The error was :" );
ApiError error = apiException.getErrors()[0];
log.error( " code: " + error.getCode() );
log.error( " detail: " + error.getDetail() );
log.error( " field: " + error.getField() );
log.error( " index: " + error.getIndex() );
log.error( " trigger: " + error.getTrigger() );
log.error( " textindex: " + error.getTextIndex() );
log.error( " textlength: " + error.getTextLength() );
log.error( " isexemptable: " + error.isIsExemptable() );
}
}

Pete
On Dec 3, 3:09 pm, AdWords API Advisor <adwordsapiadvi...@google.com>
wrote:

Peer Jakobsen (AdWords API Guru)

unread,
Dec 3, 2008, 4:42:43 PM12/3/08
to AdWords API Forum
Hi Anton,

In .NET you have to treat the error object as an xml document.
Basically you treat the exceptions Detail property as an XmlNode and
then extract the data as you would from any Xml document. You could
create the classes for the exception and error objects and then have
the deserializer cast the Detail node into those objects (I guess
thats what JAVA does automatically). I find it faster to just extract
the information needed directly from the XML.

Cheers,
Peer Jakobsen

The Detail

AKa

unread,
Dec 4, 2008, 4:41:53 AM12/4/08
to AdWords API Forum
Hello Peer,
that what I searched for. I hoped that I can use this class as in
Java. As I see in WSDL type ApiException and ApiError are present.
Can you post some very small example?

Regards
Anton Kalcik


On Dec 3, 10:42 pm, "Peer Jakobsen (AdWords API Guru)"
Reply all
Reply to author
Forward
0 new messages