@@ -20,76 +20,76 @@ public XeroApiExceptionHandler() {
2020
2121 // REFACTOR ERROR HANDLER
2222 // ACCOUNTING Validation Errors (400)
23- public void validationError (String objectType , com .xero .models .accounting .Error error ) {
24- throw new XeroBadRequestException (objectType , error );
23+ public void validationError (String objectType , com .xero .models .accounting .Error error , Exception e ) {
24+ throw new XeroBadRequestException (objectType , error , e );
2525 }
2626
2727 // ASSETS Validation Errors (400)
28- public void validationError (String objectType , com .xero .models .assets .Error error ) {
29- throw new XeroBadRequestException (objectType , error );
28+ public void validationError (String objectType , com .xero .models .assets .Error error , Exception e ) {
29+ throw new XeroBadRequestException (objectType , error , e );
3030 }
3131
3232 // BANKFEED Statements Validation Errors (400)
33- public void validationError (String objectType , Statements error ) {
34- throw new XeroBadRequestException (objectType , error );
33+ public void validationError (String objectType , Statements error , Exception e ) {
34+ throw new XeroBadRequestException (objectType , error , e );
3535 }
3636
3737 // BANKFEED Connections Validation Errors (400)
38- public void validationError (String objectType , FeedConnections error ) {
39- throw new XeroBadRequestException (objectType , error );
38+ public void validationError (String objectType , FeedConnections error , Exception e ) {
39+ throw new XeroBadRequestException (objectType , error , e );
4040 }
4141
4242 // PAYROLL UK Validation Errors
43- public void validationError (Integer statusCode , String objectType , com .xero .models .payrolluk .Problem error ) {
43+ public void validationError (Integer statusCode , String objectType , com .xero .models .payrolluk .Problem error , Exception e ) {
4444 if (statusCode == 400 ) {
45- throw new XeroBadRequestException (objectType , error );
45+ throw new XeroBadRequestException (objectType , error , e );
4646 } else if (statusCode == 405 ) {
47- throw new XeroMethodNotAllowedException (objectType , error );
47+ throw new XeroMethodNotAllowedException (objectType , error , e );
4848 }
4949 }
5050
5151 // PAYROLL NZ Validation Errors
52- public void validationError (Integer statusCode , String objectType , com .xero .models .payrollnz .Problem error ) {
52+ public void validationError (Integer statusCode , String objectType , com .xero .models .payrollnz .Problem error , Exception e ) {
5353 if (statusCode == 400 ) {
54- throw new XeroBadRequestException (objectType , error );
54+ throw new XeroBadRequestException (objectType , error , e );
5555 } else if (statusCode == 405 ) {
56- throw new XeroMethodNotAllowedException (objectType , error );
56+ throw new XeroMethodNotAllowedException (objectType , error , e );
5757 } else if (statusCode == 409 ) {
58- throw new XeroConflictException (objectType , error );
58+ throw new XeroConflictException (objectType , error , e );
5959 }
6060 }
6161
6262 // PAYROLL AU Employees Validation Errors (400)
63- public void validationError (String objectType , com .xero .models .payrollau .Employees employees ) {
64- throw new XeroBadRequestException (objectType , employees );
63+ public void validationError (String objectType , com .xero .models .payrollau .Employees employees , Exception e ) {
64+ throw new XeroBadRequestException (objectType , employees , e );
6565 }
6666
67- public void validationError (String objectType , com .xero .models .payrollau .LeaveApplications leaveApplications ) {
68- throw new XeroBadRequestException (objectType , leaveApplications );
67+ public void validationError (String objectType , com .xero .models .payrollau .LeaveApplications leaveApplications , Exception e ) {
68+ throw new XeroBadRequestException (objectType , leaveApplications , e );
6969 }
7070
71- public void validationError (String objectType , com .xero .models .payrollau .PayItems payItems ) {
72- throw new XeroBadRequestException (objectType , payItems );
71+ public void validationError (String objectType , com .xero .models .payrollau .PayItems payItems , Exception e ) {
72+ throw new XeroBadRequestException (objectType , payItems , e );
7373 }
7474
75- public void validationError (String objectType , com .xero .models .payrollau .PayRuns payRuns ) {
76- throw new XeroBadRequestException (objectType , payRuns );
75+ public void validationError (String objectType , com .xero .models .payrollau .PayRuns payRuns , Exception e ) {
76+ throw new XeroBadRequestException (objectType , payRuns , e );
7777 }
7878
79- public void validationError (String objectType , com .xero .models .payrollau .PayrollCalendars payrollCalendars ) {
80- throw new XeroBadRequestException (objectType , payrollCalendars );
79+ public void validationError (String objectType , com .xero .models .payrollau .PayrollCalendars payrollCalendars , Exception e ) {
80+ throw new XeroBadRequestException (objectType , payrollCalendars , e );
8181 }
8282
83- public void validationError (String objectType , com .xero .models .payrollau .SuperFunds superFunds ) {
84- throw new XeroBadRequestException (objectType , superFunds );
83+ public void validationError (String objectType , com .xero .models .payrollau .SuperFunds superFunds , Exception e ) {
84+ throw new XeroBadRequestException (objectType , superFunds , e );
8585 }
8686
87- public void validationError (String objectType , com .xero .models .payrollau .Timesheets timesheets ) {
88- throw new XeroBadRequestException (objectType , timesheets );
87+ public void validationError (String objectType , com .xero .models .payrollau .Timesheets timesheets , Exception e ) {
88+ throw new XeroBadRequestException (objectType , timesheets , e );
8989 }
9090
91- public void validationError (String objectType , String msg ) {
92- throw new XeroBadRequestException (400 , msg );
91+ public void validationError (String objectType , String msg , Exception e ) {
92+ throw new XeroBadRequestException (400 , msg , e );
9393 }
9494
9595 // REFACTOR GENERIC ERROR HANDLER
@@ -98,34 +98,34 @@ public void execute(HttpResponseException e) {
9898
9999 if (statusCode == 400 ) {
100100 String message = e .getMessage ();
101- throw new XeroBadRequestException (statusCode ,message );
102-
101+ throw new XeroBadRequestException (statusCode , message , e );
102+
103103 } else if (statusCode == 401 ) {
104104 String message = "Unauthorized - check your scopes and confirm access to this resource" ;
105- throw new XeroUnauthorizedException (statusCode , message );
105+ throw new XeroUnauthorizedException (statusCode , message , e );
106106
107107 } else if (statusCode == 403 ) {
108108 String message = "Forbidden - authentication unsuccessful" ;
109- throw new XeroForbiddenException (statusCode , message );
109+ throw new XeroForbiddenException (statusCode , message , e );
110110
111111 } else if (statusCode == 404 ) {
112112 String message = "The resource you're looking for cannot be found" ;
113- throw new XeroNotFoundException (statusCode , message );
113+ throw new XeroNotFoundException (statusCode , message , e );
114114
115115 } else if (statusCode == 429 ) {
116116 String message = "You've exceeded the per " + e .getHeaders ().get ("x-rate-limit-problem" ) + " rate limit" ;
117- throw new XeroRateLimitException (statusCode , message );
117+ throw new XeroRateLimitException (statusCode , message , e );
118118
119119 } else if (statusCode == 500 ) {
120120 String message = "An error occurred in Xero. Check the API Status page http://status.developer.xero.com for current service status." ;
121- throw new XeroServerErrorException (statusCode , message );
121+ throw new XeroServerErrorException (statusCode , message , e );
122122
123123 } else if (statusCode > 500 ) {
124124 String message = "Internal Server Error" ;
125- throw new XeroServerErrorException (statusCode , message );
125+ throw new XeroServerErrorException (statusCode , message , e );
126126
127127 } else {
128- throw new XeroApiException (statusCode , e .getStatusMessage ());
128+ throw new XeroApiException (statusCode , e .getStatusMessage (), e );
129129 }
130130 }
131131
@@ -139,27 +139,27 @@ public void execute(HttpResponseException e, ApiClient apiClient)
139139 TypeReference <Error > errorTypeRef = new TypeReference <Error >() {
140140 };
141141 error = apiClient .getObjectMapper ().readValue (e .getContent (), errorTypeRef );
142- throw new XeroApiException (statusCode , e .getStatusMessage (), error );
142+ throw new XeroApiException (statusCode , e .getStatusMessage (), error , e );
143143 } else if (statusCode == 404 ) {
144144 error = new Error ();
145145 Element elementsItem = new Element ();
146146 ValidationError ve = new ValidationError ();
147147 ve .setMessage ("The resource you're looking for cannot be found" );
148148 elementsItem .addValidationErrorsItem (ve );
149149 error .addElementsItem (elementsItem );
150- throw new XeroApiException (statusCode , error );
150+ throw new XeroApiException (statusCode , error , e );
151151 } else if (statusCode == 429 ) {
152152 error = new Error ();
153153 Element elementsItem = new Element ();
154154 ValidationError ve = new ValidationError ();
155155 ve .setMessage ("You've exceeded the per " + e .getHeaders ().get ("x-rate-limit-problem" ) + " rate limit" );
156156 elementsItem .addValidationErrorsItem (ve );
157157 error .addElementsItem (elementsItem );
158- throw new XeroApiException (statusCode , error );
158+ throw new XeroApiException (statusCode , error , e );
159159 } else if (statusCode == 401 ) {
160- throw new XeroApiException (401 , "Unauthorized - check your scopes and confirm access to this resource" );
160+ throw new XeroApiException (statusCode , "Unauthorized - check your scopes and confirm access to this resource" , e );
161161 } else if (statusCode != 400 ) {
162- throw new XeroApiException (statusCode , e .getStatusMessage ());
162+ throw new XeroApiException (statusCode , e .getStatusMessage (), e );
163163 } else {
164164 throw e ;
165165 }
0 commit comments