To throw a custom exception from mule flows, I am using:
<sub-flow name="throwException">
<scripting:transformer>
<scripting:script engine="Groovy">
throw new mypackage.MyCustomException();
</scripting:script>
<scripting:transformer>
</sub-flow>
Here, while throwing exception I need to send the value of an inbound property. eg:
throw new mypackage.MyCustomException("value of inbound variable");
I need to replace the above string with the value of inbound variable. How do I access eventContext/mulemessage/payload/ any scoped variables in this groovy script?
throw new mypackage.MyCustomException(message.getInboundProperty('some_variable_name'));
See here under Script Context Bindings for a list of objects available in the script context.
Related
I have a java project written using spring-cloud-function and deployed in aws-lambda.
I am trying to return a custom exception with some fields in the exception message body, something like"
{
reason: <exception reason>
code: <error code>
<some other fields>
}
#ExceptionHandler, that is generally used in spring boot doesn't seem to work here.
I can return the exception in the required format by creating a class for building the exception message in required format but in that case the error code will always be 200 since it will not be an exception object per se. Instead it will be my custom error object.
Is there a way I can set this up so that the above required format of exception object is returned and correct error code can be returned too?
Thanks in advance
First, the exception has nothing to do with Spring Boot. It's part of spring-web, so yes it would not work here since s-c-function is a general purpose framework, where the same function could be deployed and triggered via web, streaming, aws-lambda etc. .
Now, yes we had a problem returning JSON error (as you show) or object that represents the same, but that was fixed. So please update s-c-function to 3.2.3.
Currently I have a use case where I need to invoke a Mysql Procedure thorough Oracle BPEL. The adapter configuration is fine and shows me the available In/Out parameters during the configuration and the composite is deployed successfully. However the invocation is failed during the webs service call.
Any idea about the issue particularly in SOA. The weblogic version is 12c & I am using jDev 11g for the composite development.
Below is the error message received during the web service call-
The selected operation process could not be invoked.
A fault occurred while invoking the webservice operation. The fault is : <env:Fault xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<faultcode>env:Server</faultcode>
<faultstring>Exception occurred when binding was invoked.
Exception occurred during invocation of JCA binding: "JCA Binding execute of Reference operation 'getUserFirstName' failed due to: Register out parameter error.
Error registering parameter First_Name as an out parameter.
An error occurred when registering parameter First_Name as an out parameter of the getUserName API. Cause: java.sql.SQLException: Parameter number 2 is not an OUT parameter
Check to ensure that the parameter is a valid IN/OUT or OUT parameter of the API. This exception is considered retriable, likely due to a communication failure. To classify it as non-retriable instead add property nonRetriableErrorCodes with value "0" to your deployment descriptor (i.e. weblogic-ra.xml). To auto retry a retriable fault set these composite.xml properties for this invoke: jca.retry.interval, jca.retry.count, and jca.retry.backoff. All properties are integers.
".
The invoked JCA adapter raised a resource exception.
Please examine the above error message carefully to determine a resolution.
</faultstring>
<faultactor/>
<detail>
<exception>Parameter number 2 is not an OUT parameter</exception>
</detail>
</env:Fault>
oracle.sysman.emInternalSDK.webservices.util.SoapTestException: Client received SOAP Fault from server : Exception occurred when binding was invoked.
Exception occurred during invocation of JCA binding: "JCA Binding execute of Reference operation 'getUserFirstName' failed due to: Register out parameter error.
Error registering parameter First_Name as an out parameter.
An error occurred when registering parameter First_Name as an out parameter of the getUserName API. Cause: java.sql.SQLException: Parameter number 2 is not an OUT parameter
Check to ensure that the parameter is a valid IN/OUT or OUT parameter of the API. This exception is considered retriable, likely due to a communication failure. To classify it as non-retriable instead add property nonRetriableErrorCodes with value "0" to your deployment descriptor (i.e. weblogic-ra.xml). To auto retry a retriable fault set these composite.xml properties for this invoke: jca.retry.interval, jca.retry.count, and jca.retry.backoff. All properties are integers.
".
The invoked JCA adapter raised a resource exception.
Please examine the above error message carefully to determine a resolution.
Step wise DB Adapter configuration is here-
https://drive.google.com/open?id=1cei0OFje1dmefDn7PfBIjxW4vb81Ngez
I think you made a mistake while you are selecting in and out parameters, probably you have added more variable than your database are expecting. Please look at the following and if possible send more details like screenshots of your db adapter configurations and db table
java.sql.SQLException: Parameter number 2 is not an OUT parameter
Is there a way to pass any meaningful message, not “std::exception” to the promise’s fail callback? In the sources I found the following “void FB::variantDeferred::reject(std::exception e) const” specification. It seems when reject is called with any exception derived from std::exception the slicing happens and the right exception’s message is lost. Is there any workaround but to pass error through success callback?
std::exception is simply a base class for creating exceptions in C++. You can use a number of different methods to pass a specific string back; for example, you could throw a std::runtime_error, which accepts a message.
You could also subclass std::exception and provide an implementation of std::exception::what which returns a useful string representation of what you want.
FireBreath 2.0 will use the error message from e.what() when it creates the Error object. You can find this in the code, if you're curious how that works:
NPAPI
ActiveX
FireWyrm (used for Native Messaging)
What is the concept behind exception handling in Spring Integration or any other EAI framework: Are they treated as a Message?
Lets say that a JMS timeout exception was thrown from jms-outbound-gateway. Now it has to be moved all the way upto the parent custom gateway addEmployeeGateway which defines a method called addEmployee which throws a custom exception called SystemDownException. These two components are connected through request and reply channels and thats the only medium of communication. Does it mean that Exceptions are also treated as messages?
Also, if i had to map the JMS timeout exception to my custom exception SystemDownException and rethrow the SystemDownException how and where would i achieve this. I dont want to use an errorchannel.
The general mechanism for handling exceptions is an error-channel on the inbound (or some intermediate) endpoint; the ErrorMessage payload has failedMessage and cause properties.
The mechanism is similar to try {...} catch {...} in Java.
I dont want to use an errorchannel.
Alternatively, you can configure a custom request handler advice on the JMS outbound gateway; there, you can do whatever you want, including throwing your SystemDownException after catching an exception on callback.execute().
I want to convert HTTP status codes to Java Exceptions in my CXF rest client. According to the official documentation I need to use ResponseExceptionMapper, but there is no example to make it work. My understanding is that I need to register it as a provider, but how can I do that with a proxy type of client? I tried the following code
//create a proxy client
locationService = JAXRSClientFactory.create(applicationURI + "/rest/", LocationService.class);
//registering my ResponseExceptionMapper
ProviderFactory.getSharedInstance().registerUserProvider(LocationResponseExceptionMapper.getInstance());
but it is not working, because ProviderFactory.getSharedInstance() returns a different ProviderFactory instance then the instance used by my client.
Supply exception mapper to proxy factory using this signature:
//create a proxy client with specified exception mapping provider
List<Object> providers = new ArrayList<Object>();
providers.add(LocationResponseExceptionMapper.getInstance());
locationService = JAXRSClientFactory.create(applicationURI + "/rest/", LocationService.class, providers);