--The flow is to eradicate catch (Exception e) {} and write the poem that follows. --I wrote it as an Exception, but what is an error? How should I handle it? Consider --I want to tell the programmer, "It's better not to silence the Exception." --I want to tell the designer, "We should design to decide how to handle ultra-rare Exceptions."
―― "Oh, it's an exception. It doesn't occur, so I'm not sure, so you can just silently kill it. Catch (Exception e) {} is OK." ――This is the worst.
--The throwing Exception side is throwing because an abnormal situation has occurred (even if it is very rare).
--Even if an Exception occurs, it continues to operate normally as if nothing had happened. ――It's scary, but parents keep ignoring it even though they say, "My child has a headache!" ――Isn't it irreparable later? Do you regret it?
――Exceptions that are handled by design are handled properly, aren't they? (Retry of communication error) ――The problem is how to handle exceptions that are not decided by design. Therefore, the programmer chooses "The treatment has not been decided-> Silent killing is okay".
――Let's "exception that has not been decided to handle → catch and throw as it is". ――This is the correct answer.
――In the first place, exceptions that are not handled by design are extremely rare exceptions. (There is no design because it is virtually impossible to occur) ――So it almost never happens. So, whether you silently kill or throw, the code isn't actually executed, so in that sense it's the same no matter which one you choose. ――But if you choose either one, throw is better than silent killing if you think about * if it happens *. (However, when it really happens, it will be the strongest ally)
――I think that it will almost never occur now, but when it enters the operation phase, it suddenly occurs. ――There is a limit to the range (design ability) that humans can imagine. Reality goes beyond that lightly. ――If you kill yourself silently, when the reality is over, your hands and feet will not come out. There are many things you can do in the development phase, but you will die in the operation phase.
――For example, how about saying "A super rare exception is caught in the top class, logged as ERROR, and the system continues". ――See, you can throw super rare exceptions with peace of mind.
――It's super rare, isn't it? It doesn't usually occur, right? Do you really design? ――You can't just design it, right? Man-hours will increase for mounting, testing, and operation, right? -Isn't it cost-effective? Are you prepared to bear it? ――So, do you really do it?
Recommended Posts