import com.ebay.sdk.*; import com.ebay.sdk.call.GeteBayDetailsCall; import com.ebay.sdk.logging.CallMetrics; import com.ebay.soap.eBLBaseComponents.*;
public class GeteBayDetailsExceptionLogging {
private static ApiContext apiContext; private static ApiLogging logging ; private CallRetry callretry; private static String TOKEN = ""; private static String APISERVERURL = "https://api.sandbox.ebay.com/wsapi";
GeteBayDetailsExceptionLogging() { apiContext = new ApiContext(); logging = new ApiLogging(); // Retry object callretry = new CallRetry(); callretry.setMaximumRetries(3); callretry.setDelayTime(1000);
// assign the Api error code of interest String [] apiErrorCodes = new String[]{ "10007", "931" }; callretry.setTriggerApiErrorCodes(apiErrorCodes);
// assign the Exception classes of interest to Class array object java.lang.Class[] tcs = new java.lang.Class[]{ java.net.SocketTimeoutException.class, com.ebay.sdk.SdkSoapException.class }; callretry.setTriggerExceptions(tcs);
// assign Http Status Codes
int[] httpErrorCode = { 502};
com.ebay.sdk.ExceptionFilter excfilter = new com.ebay.sdk.ExceptionFilter(); excfilter.setTriggerApiErrorCodes(apiErrorCodes); excfilter.setTriggerExceptions(tcs); excfilter.setTriggerHTTPErrorCodes(httpErrorCode);
// register Exception filter logging.setMessageLoggingFilter(excfilter); logging.setLogExceptions(true); apiContext.setApiLogging(logging); }
public static void main(String[] args) { GeteBayDetailsExceptionLogging gbdel= new GeteBayDetailsExceptionLogging (); ApiCredential cred = new ApiCredential(); apiContext.setApiCredential(cred); //set api call credential apiContext.getApiCredential().seteBayToken(TOKEN); apiContext.setApiServerUrl(APISERVERURL);
GeteBayDetailsCall api = new GeteBayDetailsCall(gbdel.apiContext); try { api.geteBayDetails(); } catch (Throwable e) { // handle the exception here }
}} |