Closed ri4a closed 2 months ago
This can be achieved with the current solution like this:
final Wrapper <Phase4Exception> aSendingExceptionKeeper = new Wrapper <> ();
Phase4PeppolSender.builder ()....sendMessageAndCheckForReceipt (aSendingExceptionKeeper::set);
final Phase4Exception aSendingEx = aSendingExceptionKeeper.get ();
if (aSendingEx != null)
{
if (aSendingEx.getCause () instanceof ExtendedHttpResponseException)
{
final ExtendedHttpResponseException exr = (ExtendedHttpResponseException) aSendingEx.getCause ();
LOGGER.error ("Error sending Peppol message via AS4 due to HTTP status code " + exr.getStatusCode ());
}
else
LOGGER.error ("Exception sending AS4 user message", aSendingEx);
}
The ExtendedHttpResponseException
has access to other parts of the HTTP response as well
Fantastic Philip, thank you!
When sending a document fails with an HTTP error, it is not currently possible to determine this and get the HTTP error. That would be very helpful, since that error message could be shown/sent to the sender in the UI/webhook. With the HTTP response code it would also be possible to determine whether a retry could work (500: yes, 400: probably not).