I wan to send exception message from one quarkus service and another quarkus service. How do I do that? - exception

I have two services, If any exception is thrown is one service I should be able to receive that exception is other service which is making the call to that service. In short I want to communicate the exception body from one service to another.
Currently the exception response is :
Received: 'Server response is: 500' when invoking: Rest Client method: 'XXX' regardless of whatever the exception message is thrown.
I want the exception message message to be communicated to the calling services.
Solution but not conventional : The Error message I am currently sending throw headers, The exception body is not picked.

From your service1 you send Response with any http status you want. At your service2 to while writing client you need to catch WebApplicationException to know what status returned by service1 client.
[Optional]
You can use org.eclipse.microprofile.rest.client.ext.ResponseExceptionMapper to map http response status to your custom exceptions at your service2

Related

Circular error-handler detected at route: {} - breaking out processing Exchange: {}

I am having multiple camel routes written in Java DSL exceptions are handled using OnException.
Below are my requirements.
Fetch token from cache and make http call
If http call fails with invalid token then make a back end call to get new token and then make http call
If http call fails with specific error then needs to handle it properly.
Issue:
If http call fails with invalid token then it is making backend call to fetch the token and then calling http request using exception handling code. Now the http call failed again while calling from OnException with some other error and it is not going to OnException and giving circular error handler message.
Please help me to handle this error. Thankyou
I am using SpringBoot camel starter 3.8.0 and Java 11

BizTalk - Why does a suspended message appear in the console for a handled exception?

Here is an image of a common structure we have in a few of our BizTalk orchestrations:
So when we GET information from an API and the account doesn't exist, we terminate the orchestration. This works fine and I can see the orchestration doing this and terminating when it should, but what I don't understand is why do I see the suspended message from the GET in the console? Since the exception handling works, shouldn't this stop an error showing in the console?
As a way around this, I've considered using a pipeline component to check the response message, and if it contains what would be ignored, just return null in place of the message. Would this have the desired effect? I'm more interested as to why I see the suspended messages in the console.
Yes, this is a known issue with the WCF-WebHttp adapter, that has to do with the fact that it throws it back as a SOAP formatted error, but without setting the MessageType context property (see my blog post and look for Bug: BizTalk WCF-WebHttp adapter does not set the message type on error). So although the exception is thrown back at the Orchestration and can be handled there, the message is not as BizTalk does not know what type it is and it suspends.
A workaround we use is
To set Enable Routing for failed messages on the send port
To have a send port that subscribes to all the response messages from that send port using the BTS.SPName = xxxx filter, and send port sends it to a custom NULL adapter (throw the message away), and yes, your Orchestration will still get the good response as well as the exceptions.
Update the send port that handles routing errors from other send ports that we do want to go to our exception handing to exclude those send ports which we are handling via an Orchestration.

Camel exception before reaching route

I have a restlet route as below
from("restlet:/api?restletMethod=GET").log("API Reached");
The problem is from("restlet:/api?restletMethod=GET") throws an exception when I send an invalid url like http://localhost:8080/api?query=%s%n%s.
How to handle this exception? onException is not working as the request is not reaching the route
I believe you should configure endpoint like this.
RestletEndpoint endpoint = context.getEndpoint("restlet:http://localhost:8080/api", RestletEndpoint.class);
endpoint.configureProperties(Collections.singletonMap("bridgeErrorHandler", true));

UrlFetchApp.fetch - need HTTP response status

I am trying to obtain the status message of the response to a POST to a rest service via:
var response = UrlFetchApp.fetch(<url>, <params>);
I need the status description as reported by the server which does not appear to be available as part of the HTTPResponse object returned by the fetch method.
I can get the status code using:
response.getResponseCode();
But no luck on the message associated with it. I have wrapped the fetch call in a try/catch block, but the error message returned using that method is an error message provided by the spreadsheet service, not the original, raw status description from the server response.
Any ideas on how to obtain this piece of information, most appreciated.
The associated message from the service should be available in HTTPResponse.getContentText(). You'll need to pass the optional parameter muteHttpExceptions set to true in the UrlFetchApp.fetch() request to prevent an exception from being thrown.

Intercept Http Endpoint Exception [Mule ESB]

I'am using Mule 3.3.0 CE and I would have a custom behaviour when an exception is thrown in an http outbound endpoint (i.e when I get a Connection Refused Exception or Connection Timeout Exception). Let's assume that I have this scenario: a SOAP Component and a Http Outbound Endpoint that realize together a cxf service client and let's assume that I can't use any exception strategy.
I would write an Interceptor which intercept the http exception (i.e Connection Refused) and in which I can write a custon behaviour (i.e send the message in a queue).
I need of an interceptor that intercept che http exception and no a SOAP Fault (that could be intercepted with a SOAPFaultInterceptor).
How can I realize this model?
Thank you all for any help
I found the solution. I used a custom interceptor ( component) just before the Http component and I extended the AbstractEnvelopeInterceptor that gives to me the possibility to work before, after and during the component is processing the message.
With this perspective, I implemented the last method. This method's sign contains a boolean value that is setted is an exception occurred. In this way I can leverage this method to handle any kind of exceptions that is related to Http Component.