Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give access to the HTTP error response #224

Closed
ri4a opened this issue Mar 1, 2024 · 2 comments
Closed

Give access to the HTTP error response #224

ri4a opened this issue Mar 1, 2024 · 2 comments
Assignees
Labels

Comments

@ri4a
Copy link

ri4a commented Mar 1, 2024

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).

@phax phax self-assigned this Mar 4, 2024
@phax
Copy link
Owner

phax commented Jun 25, 2024

This can be achieved with the current solution like this:

  1. remember the exception in sending:
final Wrapper <Phase4Exception> aSendingExceptionKeeper = new Wrapper <> ();
Phase4PeppolSender.builder ()....sendMessageAndCheckForReceipt (aSendingExceptionKeeper::set);
  1. afterwards evaluate the sending exception
      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

@phax phax added question and removed enhancement labels Jun 25, 2024
@ri4a
Copy link
Author

ri4a commented Jun 25, 2024

Fantastic Philip, thank you!

@ri4a ri4a closed this as completed Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants