The NumberFormatException is not in any catch sentence but if parseInt throw the NumberFormatException the SQLException | ClassNotFoundException catch block is running (I can't figure why), if I rewrite the code:

I interpret differently: in your first example the parseInt() is not causing an exception, so the code goes on to the f.save(), blows up and throws an SQLException. In stead of hiding the information, add printStackTrace() calls to your exception handling blocks and see the actual exception that is being caused and by which statement.

02-11-2014, 03:28 PM

GuteFco

Re: Multiple catch bug?

Quote:

Originally Posted by gimbal2

I interpret differently: in your first example the parseInt() is not causing an exception, so the code goes on to the f.save(), blows up and throws an SQLException. In stead of hiding the information, add printStackTrace() calls to your exception handling blocks and see the actual exception that is being caused and by which statement.

I get the stacktrace it says:

Code:

java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:592)
at java.lang.Integer.parseInt(Integer.java:615)
at cl.pollero.controladores.CrearFamiliaController.lambda$configurarBotonCrear$1(CrearFamiliaController.java:92)
...

the line with the:

Code:

f.setStock(Integer.parseInt(tflStock.getText()));

any way, if you ask me the two snipped code (multiple catch and one catch at time) are the same, but they work differently, I'm using Java 8, may be a bug?

02-11-2014, 03:57 PM

gimbal2

Re: Multiple catch bug?

I can't say, I'm not a developer on the Java 8 development team and I am not going to consider using it before it has been officially released and had at least two patch releases. If you can produce a small test application which shows the problem, I'll be happy to take a look running it through Java 7.

02-11-2014, 04:04 PM

GuteFco

Re: Multiple catch bug?

I fix the problem, the try catch is right, the problem was in the outter code (an EventHandler), example: