The error disappears because your code is now valid. (Dislike, but valid.)
If the finally block has only a strict return; , then the generic try / catch / finally or try / finally statement cannot throw any exceptions - so you don't need to declare that it can throw an exception.
In your source code, your try block could (well, it will) throw an Exception (or CustomException into your real code, apparently) - and this is a test exception, which means you need to either catch it or declare that the method can throw it .
source share