+ 26

Throw multiple exceptions at the same time.

Is it possible to throw multiple exceptions at the same time in Java? maybe a work around the language features?

21st May 2018, 11:18 AM
Amir
Amir - avatar
5 Respostas
+ 24
Ulisses Cruz : I want to invoke a combination of different exception handlers at the same time... maybe it can be achieved by Events. 🤔🤔 yeah I can implement a similar behaviour using Events I think
21st May 2018, 12:09 PM
Amir
Amir - avatar
+ 4
Yes. You can throw an ARRAY out of Bounds exception, a .io* Exception, and others. Have done so. Such cluttered console! :)
22nd May 2018, 1:31 AM
Apple Blossom
Apple Blossom - avatar
+ 1
I don't think it is possible. Why would you do that?
21st May 2018, 11:21 AM
Ulisses Cruz
Ulisses Cruz - avatar
+ 1
I advise you to use events so, throwing exceptions is expensive (slow) to be used with purpose. Exceptions should really be thrown, when something goes wrong (unexpected event or illegal state). I would say avoid exceptions where you can. Building some application mechanics which is controlled by (expects) throwables is not a good idea. First it may seem handy and fast, but it is quite the opposite.
23rd May 2018, 3:10 PM
Magyar Dávid
Magyar Dávid - avatar
+ 1
processing exception runtime does something known as stack unwind, which may finish in Os, what known as program failure. you can re throw something on this way, but you can not enter this special mode twice
23rd Aug 2018, 7:42 PM
Арсений Чеботарёв
Арсений Чеботарёв - avatar