All exceptions that occur while the Solution thread is running must be handled by one of these options:
1. If it's an Error, then display "Can't keep running".
2. If it's an Exception, then display "Needs handling".
3. If it's a Throwable, then display "Wait and see".
Implement this logic.
Wait and see
- 14
Locked
Comments (3)
- Popular
- New
- Old
You must be signed in to leave a comment
Justin Smith
19 January 2022, 20:59
Hidden condition: The messages are meant to be exclusive of each other. In other words, only one message should ever be displayed. For example, e is always a Throwable (per method definition), which would imply based on the stated conditions that it should show the message for a Throwable regardless of whether or not e is also an Error or Exception. Only looking at the solution made this requirement clear.
0
Adrian
20 January 2022, 00:51
so funny story, I just solved this task, read up on throwable and saw that Exception and Error are subclasses, realized I could use the isinstanceof operator, but my code wouldn't verify.
turns out it's because I had an "if" instead of "else if"
my issue is, while e is always a throwable, it is not an instance of either of its subclasses, so I can't see it being possible for more than one output to get printed
+1
Baurzhan Konurbayev
4 April 2021, 13:35
When I used currentThread() to set exception handler, it didn't work for me. So, I had to use this instead.
0