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.
Related
I don't get the difference between Rejection and Exception in akka-http, they look redundant to me since they are managed almost the same way.
Is is not possible to have a Rejection of type Exception so in our Directives we can catch Exception and trigger the appropriate Rejection instead.
The difference between Rejection and Exception is semantic.
Rejection allows you to do validation of request parameters. If some of the parameters do not match(incorrect for this directive) than directive can reject the request and some other directives can try to match request and handle than.
Exception means that you have unexpected behavior in your directive. Usually, it is after matching when directive processes request.
As I understand from your question you can have one of the situations below:
You have exception while matching directive it probably means that you can not do proper validation and the only way is call function and look for exception. If an exception is thrown it means that directive does not match and you create rejection.
You create rejection as a part of exception handling. It is one of the ways of handling exception. Another one is just returning response with 501 status code and Internal Server Error.
Both of this situations make sense but they do not mean that rejection and exception are similar things.
Why do we catch NoSuchElementException? It makes sense to catch the exception when we only verify the presence of an element in a particular page and not performing any actions on it. We can catch this exception and log a custom message like "Element not found"
When we are about to click an element and if it is not found in the page, selenium throws NoSuchElementException. What is the use of catching this exception instead of letting it to halt the test and failing the testcase?
Note: My subsequent steps depends on this clicking step.
One reason to catch the exception is to provide more relevant test failure output. For example, if a div element isn't found in a page of 20-30 divs, cause the selector doesn't match that specific div, you could let the exception remain uncaught with a generic error message or you could catch it and throw a different exception with error message "navbar is missing".
If it is clear from the generic error message what is wrong, or you have a test failure message that explains it, there is no reason to catch it.
A different reason to catch this exception is that it's part of skip code (skip this test if/unless). So you look for an element and if it's present you proceed with the test, if it's not - you skip it.
There may be other reasons, but these are two common ones.
There are two types of Exceptions:
1.Checked Exceptions
2.Unchecked Exceptions
Checked Exceptions are checked at compile time only, these should be handled by the programmer. Compiler will check at compile time whether these exceptions are handled or not if not compile time error occurs. Some of the checked exceptions are IOException, FileNotFoundExpection,etc.
Unchecked Exceptions:
Unchecked exceptions are not checked by compiler at the time of compilation. the exceptions which are extended by RuntimeException class are all unchecked exceptions. Some of the unchecked exceptions are AritmeticException, NullPointerException etc. In selenium we see unchecked exceptions such as NoSuchElementException, StaleElementReferenceException , NoSuchWindowException, TimeoutException etc.
In short, Checked exceptions must be caught. RuntimeException, also called unchecked exceptions, should not be caught
More info can be found on
http://toolsqa.com/selenium-webdriver/exception-handling-selenium-webdriver/
http://www.seleniumeasy.com/java-tutorials/exception-handling-in-selenium-webdriver-using-java-examples
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.
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.
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!