Hi all,
I am wondering what exception handling using v2009 should be
implemented.
(I use Java.)
For example,
Version 1:
public String getErrorReason(ApiError error) {
if (error instanceof AdError) {
// return reason.
} else if (error instanceof AdExtensionError) {
// return reason.
} else if (error instanceof AdExtensionOverrideError) {
// return reason.
} else if (AdGroupAdCountLimitExceeded) {
// return reason.
} else if (AdGroupAdError) {
// return return.
} else if ...
snip...
} else if (error instanceof TargetError) {
// return reason.
}
}
Version 2:
public String getErrorReason(ApiError error) {
Method method = null;
try {
method = error.getClass().getDeclaredMethod("getReason");
} catch (SecurityException e) {
// return message
} catch (NoSuchMethodException e) {
// process the class which is not implemented 'getReason()'
}
String errorReason = null;
try {
errorReason = (String) method.invoke(error).toString();
} catch (IllegalArgumentException e) {
// return message
} catch (IllegalAccessException e) {
// return message
} catch (InvocationTargetException e) {
// return message
}
return error.getgetApiErrorType() + "." + errorReason;
}
Both Version 1 and Version 2 may by bad practice , I think...
Do you have any good ideas?
--
You received this message because you are subscribed to the Google Groups
"AdWords API Forum" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en.