The problem is that the exception goes through several layers of abstraction and at every level it is wrapped in another exception with a different class. You need to navigate the wrapped exception list to find your exception. I picked up the following code from Stackoverflow
Exception cause = e;
MyException my_exception= null;
while( cause != null && !( cause instanceof MyException) ) {
my_exception = (MyException) cause;
cause = cause.getCause();
}
if ( my_exception != null )
// DO SOMETHING
else
// it must be another exception
Hello Pim,
I've previously looked into obtaining a clear message and couldn't find a proper solution - to me it looks like the ThrowException java action is simply wrapping the default Exception class and raising it as normal, and Mendix seems to be adding the extra trace to it (I might be wrong).
We've worked around it by adding a tag to the exception and then catching all errors. If the tag is found in the caught error we exclude the stacktrace from the error message since it's of no use, we also use this to display custom messages to users.
It's quite dirty but we couldn't find any better way.
Disclaimer: It seems images might not fit within the display window - if they seem cut off you might need to download them for the whole picture.