Catching custom exceptions

  • 6
  • Locked
Perhaps you think multi-layered exception structures are evil and difficult. In reality, exceptions are simple and one of the most valuable parts of Java. This may be hard to believe on Level 9, but working with exceptions seems super confusing because it is still unfamiliar. Let's move forward without fear: in this task, you'll need to catch custom exceptions.
You can't complete this task, because you're not signed in.
Comments (12)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Xavi Martin
Level 22
Expert
6 December 2022, 07:19
No entiendo nada, que narices eso de Bean ahora? que cuesta dar una pequeña explicacion antes? Si quisiera estar buscando en google todo el dia no estaria haciendo este curso. Con estas cosas cosntantemente se me quitan las ganas. +
Carlos Enrique Arenas
Level 2 , United States
27 July 2022, 04:03
stuck in the last requirement, in the main only the FileSystemException is log it, and also called to BEAN.log method
1 October 2021, 22:04
sayàn!
Michael
Level 10 , Dresden, Germany
31 August 2021, 07:59
"2. The handleExceptions method should log the FileSystemException (call the BEAN.log method), and then rethrow it. 3. The handleExceptions method should only log (call the BEAN.log method) the CharConversionException. 4. The handleExceptions method should only log any IOException." Aren't these requirements mutually exclusive? This task is quite complicated in itself. The statement of requirements could help to clear the path to a solution, instead it obfuscates.
Andrei
Level 41
11 November 2020, 16:42
I have barely any idea what I just did, I let my fingers type.. maybe tomorrow it will make more sense, today my brain is fried, haha! P.S. When I first saw this at the beginning of the day I said to myself "there's no way I'm going to be able to do this today".. but at the end of the day, when I focused a bit on it, and broke it down.. somehow I managed lol. P.P.S. Shouldn't main be throwing Exception ? Considering it handles one?
public static void main(String[] args) throws Exception{
Gellert Varga
Level 23 , Szekesfehervar, Hungary
5 February 2021, 15:41
There can be occured three types of Exceptions: 0.) CharConversionException 1.) FileSystemException 2.) IOException The handleExceptions() method catches the type 0.) and the type 2.). So, when the program will go further then these two types can not exist anymore. They are dead. They were caught. (in the "catch" thread this is what JVM does with the trapped exceptions. It kill them.) But the handleExceptions() method won't kill the type 1.), rather it will be thrown (passed) to the main() method. But the "catch" thread in the main() method will catch (kill) him, too. So, there were no more exceptions left, they were all caught. So when program finishes and exits the main(), you no longer be able to throw any exceptions anywhere. So you don't have to write this: public static void main (String [] args) throws Exception {
Roman Grygorczuk
Level 19 , Cracow, Poland
28 October 2020, 07:48
It's very hard for me. I cannot get it at all.
Vitalina
Level 20 , Poland
20 October 2020, 22:13
I resolved it in one time but it was hard for me to understand what they want me to do...
Switch/Cypher
Level 25 , Bexleyheath, United Kingdom
19 September 2020, 15:52
How do I log and rethrow the FileSystemException without catching it? Following the code given in the hint, you need to catch it to rethrow it, and then it won't compile because FileSystemException has already been caught.....
Switch/Cypher
Level 25 , Bexleyheath, United Kingdom
19 September 2020, 16:19
OK right, order is very important here.....
Kent Hervey Software Engineer/Consult at Zeal IT ConsultantsExpert
11 February 2020, 22:10
Like so many things in life, this seemed impossible until I tried making incremental changes and monitoring the results....
Daniel
Level 15 , Colnbrook, United Kingdom
26 February 2020, 16:48
Yep, exactly the same for me. Luckily the IDE is helpful in making suggestions and fixing errors.