Accessing exception from different exception strategy types in Mule - mule

When using catch-exception-strategy in mule, I can access the exception via MEL using #[exception], but this doesn't work for default-exception-strategy. Instead I have to use #[payload.getException()]. Is this the correct behavior? And why is this?

Hi one solution is you can set your catch exception strategy as default exception strategy defined it globally. This is strange actually but you can go ahead with this solution.

Related

when it is correct purpose of exceptions

I am studying OOP, and I did not understood the concept of exception.
What are the correct uses of exceptions?
Why use exceptions when you already know a possible exception?
For example, I have seen a code sample where the programmer needed to access a file, and had an exception in case the file does not exist. Something like "catch(fileDoesNotExist e)".
Why not use an if to verify before take the action? And use exception only for not known issues, for logging or error messages.
The idea behind the concept of exception was to decouple the error handling code from the "normal" behaviour flow control. That lets to manage/handle the exception further up the call stack.
Historically, with structured language, error handling code (file opening error,...) was mixed within the "business" application code. It was also painful to improve the code in order to manage new error codes.
What are the correct uses of exceptions?
If it is not normal that your file doesn't exist or cannot be opened => it is considered as an exceptional situation => exception => exception handler
Why use exceptions when you already know a possible exception?
To decouple the business application code from the error handling. That eases source code readibility and maintenance.
Exception:
Exception is that interrupt(break) the normal flow of the program.It's thrown at runtime.
Exception Handling
Exception Handling is a mechanism to handle runtime errors such as ClassNotFound, IO, SQL, Remote etc
In java there are mainly two types of exception that checked and unchecked.Other than Error is there
Hierarchy of Exception classes in Java
Why use exceptions when you already know a possible exception?
basically exception handling use to mainly,we assuming in that our particular code will occur some(NullPointerException,ArrayIndexOutOfBoundsException etc..)exception.If we not Handle that,program will break.Actually that Exception it may or may not will happen.But so we need to handle normal flow of the program it occurred or not.Otherwise after that particular code section not executing.

Assert exception thrown in MUnit, Mulesoft

Is there a way to assert that a flow reference threw an exception in Mulesoft? Searching Google and the documentation isn't turning up anything.
Basically I'm testing a subflow that throws a NotFound exception if a certain item exists, but MUnit fails when it receives the error, even though it's expected.
I know I could mock my validator and have it return specific data which I then check for, but I was hoping there's something native that can do this that's less hacky.
I think what you're looking for is the 'expectException' attribute on the test itself. HTH.

Mule global catch exception not being called

I'm using the global exception strategy at this link
Global Catch Exception Strategy is not used
I use a ref to this in each of my flow footers and have also used defaultExceptionStrategy-ref="catchExceptionStrategy" as shown in the link. But this exception
org.mule.exception.DefaultSystemExceptionStrategy: Caught exception in Exception Strategy: null
java.util.ConcurrentModificationException
...
is not being caught by my global exception. My assumption was that this is a message exception and the flow refs would therefore direct it to the global catch. Also that the defaultExceptionStrategy-ref configuration would direct any other exceptions to the global catch.
The log you are showing proves that the exception strategy is actually called but there has been a concurrent modification exception on it. In order to help you further we would need to understand better what is in you message when the exception happens and the actual xml of your exception strategy.

Handling pgPL/SQL exceptions From QtSQL

Short and simple:
How to catch pgPL/SQL exceptions with QtSQL?
I haven't found any example or info at the docs.
More details:
I'm developing the front end for a system with Qt 5.3. The database perform some validation at some of the inputs and raise custom exceptions when something is invalid. What I want is to be able to handle these exceptions at he front end code, showing appropriate messages to the user.
EDIT:
I have tried to use the QSqlError class. Although it gave me the exception, it gave me too much data which will need to be parsed to be useful. Is there a way to get the exception raised without parsing the messages?

Exceptions from WCF

What exceptions can be thrown from a WCF client?
I usually catch CommunicationFaultedException, CommunicationException, TimoutException and some other but from time to time new ones occur, e.g. most recently QuotaExceededException
There is no common base to catch (except Exception) so does anyone have a complete list?
This might be a good place to start: Expected Exceptions.
Why would there be a complete list? This isn't Java.
Why do you want to catch an exception you don't understand? How would you "handle" it if you don't know what it means?
Go ahead and catch exceptions to log them, if you like, but you should rethrow after you catch it. Let the exception propagate up to some code that knows what to do with it.
Just thinking outloud... one solution could be:
Add the list of exceptions(and exception casting) in your Custom exception class; for instance CException.
As soon as you catch an exception in your Exception block, throw another exception into your CException class. For instance like following:
catch(Exception ex){throw new CException("An error occured", ex);}
See this example.
The CommunicationException is the base exception for all WCF exceptions. If you catch that, you catch everything WCF related.
See the MSDN docs for CommunicationException. It will also nicely show a list of all derived classes, e.g. all more specific exceptions that can occur in WCF - quite a long list!