public class XeroExceptionHandler extends Object
XeroJAXBMarshaller| Constructor and Description |
|---|
XeroExceptionHandler() |
| Modifier and Type | Method and Description |
|---|---|
XeroApiException |
convertException(IOException ioe)
For backwards comparability with xero-java-sdk version 0.6.0 keep the old way of handling exceptions
|
XeroApiException |
handleBadRequest(com.google.api.client.http.HttpResponseException httpResponseException)
Handle a HTTP 400 Bad Request from Xero.
|
XeroApiException |
handleBadRequest(String content) |
XeroApiException |
handleBadRequest(String content,
int code) |
XeroApiException |
handleBadRequest(String content,
int code,
boolean isJson) |
XeroApiException |
newApiException(com.google.api.client.http.HttpResponseException httpResponseException)
For backwards comparability with xero-java-sdk version 0.6.0 keep the old way of handling exceptions
|
XeroApiException |
newApiException(String content,
int code) |
public XeroApiException handleBadRequest(com.google.api.client.http.HttpResponseException httpResponseException)
XeroApiException
containing ApiException element with a useful summary of the reason for the error.
Use ApiException to get a list of the errors pertaining to the call in question.
For example: if you use XeroClient.createPayments(List) and this fails
with a XeroApiException, you can extract details from the exception with the following code example.
List<Elements> elements = xeroApiException.getApiException().getElements();Elementselement = elements.get(0); List<Object> dataContractBase = element.getDataContractBase(); for (Object dataContract : dataContractBase) {PaymentfailedPayment = (Payment) dataContract;ArrayOfValidationErrorvalidationErrors = failedPayment.getValidationErrors(); ... }
Or if you use XeroClient.createInvoices(List) and this fails
with a XeroApiException, you can extract details from the exception with the following code example.
List<Elements> elements = xeroApiException.getApiException().getElements();Elementselement = elements.get(0); List<Object> dataContractBase = element.getDataContractBase(); for (Object dataContract : dataContractBase) {InvoicefailedInvoice = (Invoice) dataContract;ArrayOfValidationErrorvalidationErrors = failedInvoice.getValidationErrors(); ... }
httpResponseException - the exception to handleApiException with a useful summary of the reason for the error.public XeroApiException handleBadRequest(String content)
public XeroApiException handleBadRequest(String content, int code, boolean isJson)
public XeroApiException handleBadRequest(String content, int code)
public XeroApiException convertException(IOException ioe)
ioe - exception to convertpublic XeroApiException newApiException(com.google.api.client.http.HttpResponseException httpResponseException)
httpResponseException - exception to handlepublic XeroApiException newApiException(String content, int code)
Copyright © 2018. All rights reserved.