@@ -1010,7 +1010,7 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
10101010 }
10111011 } else if (object .equals ("Errors" )) {
10121012
1013- /* CONTACT */
1013+ // CONTACT
10141014 ArrayOfContact array = new ArrayOfContact ();
10151015 Contact contact = new Contact ();
10161016 contact .setName ("Sidney Maestre" );
@@ -1052,20 +1052,6 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
10521052 messages .add ("Error Code : " + e .getResponseCode () + " Message: " + e .getMessage ());
10531053 }
10541054
1055- // FORCE a 503 Error
1056- List <Contact > ContactList = client .getContacts ();
1057- int num4 = SampleData .findRandomNum (ContactList .size ());
1058- try {
1059- for (int i =65 ; i >1 ; i --){
1060- Contact ContactOne = client .getContact (ContactList .get (num4 ).getContactID ());
1061- }
1062- messages .add ("Congrats - you made over 60 calls without hitting rate limit" );
1063- } catch (XeroApiException e ) {
1064- System .out .println (e .getResponseCode ());
1065- System .out .println (e .getMessage ());
1066- messages .add ("Error Code : " + e .getResponseCode () + " Message: " + e .getMessage ());
1067- }
1068-
10691055 try {
10701056 List <Invoice > listOfInvoices = new ArrayList <Invoice >();
10711057 listOfInvoices .add (SampleData .loadBadInvoice ().getInvoice ().get (0 ));
@@ -1076,20 +1062,37 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
10761062
10771063 } catch (XeroApiException e ) {
10781064 int code = e .getResponseCode ();
1079- List <Elements > elements = e .getApiException ().getElements ();
10801065
1081- if (e .getApiException ().getElements ().size () > 0 ) {
1082- Elements element = elements .get (0 );
1083- List <Object > dataContractBase = element .getDataContractBase ();
1084- for (Object dataContract : dataContractBase ) {
1085- Invoice failedInvoice = (Invoice ) dataContract ;
1086- ArrayOfValidationError validationErrors = failedInvoice .getValidationErrors ();
1087- List <ValidationError > errors = validationErrors .getValidationError ();
1088-
1089- messages .add ("Error Code:" + e .getResponseCode () + " message : " + errors .get (0 ).getMessage ());
1090- messages .add ("Error invoice Num : " + failedInvoice .getInvoiceNumber ());
1066+ if (code == 400 ) {
1067+ List <Elements > elements = e .getApiException ().getElements ();
1068+
1069+ if (e .getApiException ().getElements ().size () > 0 ) {
1070+ Elements element = elements .get (0 );
1071+ List <Object > dataContractBase = element .getDataContractBase ();
1072+ for (Object dataContract : dataContractBase ) {
1073+ Invoice failedInvoice = (Invoice ) dataContract ;
1074+ ArrayOfValidationError validationErrors = failedInvoice .getValidationErrors ();
1075+ List <ValidationError > errors = validationErrors .getValidationError ();
1076+
1077+ messages .add ("Error Code:" + e .getResponseCode () + " message : " + errors .get (0 ).getMessage ());
1078+ messages .add ("Error invoice Num : " + failedInvoice .getInvoiceNumber ());
1079+ }
10911080 }
10921081 }
1082+ }
1083+
1084+ // FORCE a 503 Error
1085+ List <Contact > ContactList = client .getContacts ();
1086+ int num4 = SampleData .findRandomNum (ContactList .size ());
1087+ try {
1088+ for (int i =65 ; i >1 ; i --){
1089+ Contact ContactOne = client .getContact (ContactList .get (num4 ).getContactID ());
1090+ }
1091+ messages .add ("Congrats - you made over 60 calls without hitting rate limit" );
1092+ } catch (XeroApiException e ) {
1093+ System .out .println (e .getResponseCode ());
1094+ System .out .println (e .getMessage ());
1095+ messages .add ("Error Code : " + e .getResponseCode () + " Message: " + e .getMessage ());
10931096 }
10941097 }
10951098
0 commit comments