How to know which exception can be thrown in C #?

5

If in Java I invoke the void cadastra() throws SQLException method for example, I will be forced to add a try catch block or to "re-launch" the exception that can be thrown by this method.

So, right away I know which exception can be thrown.

Now, in C #, how do I know what exceptions the void Cadastra() method can throw?

    
asked by anonymous 29.06.2017 / 02:34

1 answer

3

Reading documentation or using any tool that helps you know by informing which exceptions can be thrown. Although this is not so accurate, so capturing Exception is not a good idea.

If you re-launch the exception you are doing something wrong, if you just re-launch it do not capture it. People capture far more exceptions than they should. They can hardly ever do anything useful with it. So let it spread.

In Java, too, there are not many exceptions, and the ones they have are considered problematic in many situations even by most Java programmers who know what they are talking about.

For all this I think exception a wrong engine most of the time .

The Java mechanism that indicates that an exception can be thrown is very controversial and practice has shown that it brings more problems than solutions.

    
29.06.2017 / 02:49