From ecff5f9bfe21f47694d948bb752c2d8c3c7ef1d7 Mon Sep 17 00:00:00 2001 From: Chris Mitchell Date: Fri, 27 Feb 2026 13:57:27 +1300 Subject: [PATCH] fix: add error handling for Payroll AU V2 API In preparation for new API being added --- .../java/com/xero/api/XeroApiExceptionHandler.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/java/com/xero/api/XeroApiExceptionHandler.java b/src/main/java/com/xero/api/XeroApiExceptionHandler.java index 828a3682..df9ba3bf 100644 --- a/src/main/java/com/xero/api/XeroApiExceptionHandler.java +++ b/src/main/java/com/xero/api/XeroApiExceptionHandler.java @@ -69,6 +69,20 @@ public void validationError(Integer statusCode, String objectType, com.xero.mode throw new XeroMethodNotAllowedException(objectType, error, e); } } + + /** Handle Validation Errors (400) + * @param statusCode Integer the server status code returned. + * @param objectType String object type being interacted with when the error was returned. + * @param error Problem object with details specific to UK Payroll API + * @param e Exception object with details about the original exception + */ + public void validationError(Integer statusCode, String objectType, com.xero.models.payrollauv2.Problem error, Exception e) { + if (statusCode == 400 ) { + throw new XeroBadRequestException(objectType, error, e); + } else if(statusCode == 405) { + throw new XeroMethodNotAllowedException(objectType, error, e); + } + } /** Handle Validation Errors (400) * @param statusCode Integer the server status code returned.