Skip to content

Commit a34b373

Browse files
author
Chris Mitchell
committed
fix: add correct error handling for newly added api
1 parent 381027c commit a34b373

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/main/java/com/xero/api/XeroApiExceptionHandler.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,20 @@ public void validationError(Integer statusCode, String objectType, com.xero.mode
6969
throw new XeroMethodNotAllowedException(objectType, error, e);
7070
}
7171
}
72+
73+
/** Handle Validation Errors (400)
74+
* @param statusCode Integer the server status code returned.
75+
* @param objectType String object type being interacted with when the error was returned.
76+
* @param error Problem object with details specific to UK Payroll API
77+
* @param e Exception object with details about the original exception
78+
*/
79+
public void validationError(Integer statusCode, String objectType, com.xero.models.payrollauv2.Problem error, Exception e) {
80+
if (statusCode == 400 ) {
81+
throw new XeroBadRequestException(objectType, error, e);
82+
} else if(statusCode == 405) {
83+
throw new XeroMethodNotAllowedException(objectType, error, e);
84+
}
85+
}
7286

7387
/** Handle Validation Errors (400)
7488
* @param statusCode Integer the server status code returned.

0 commit comments

Comments
 (0)