3 ms·
(replying to both) protocol stack logic is just that... logic, no need to short circuit returns with the use of exceptions. Exceptional case are things that y
by TickleSteve 10y ago
(replying to both)
protocol stack logic is just that... logic, no need to short circuit returns with the use of exceptions.
Exceptional case are things that you have a-priori determined to be constant, i.e. the existence of a FLASH device, an RTC working correctly for example.
If any of those devices fail, it could be considered an exceptional case, therefore the only action left to you is to reset and hope the condition clears. boot-loops obviously have to be handled also.
There is a world of difference between defined recovery cases and just throwing an exception because you dont know how to "handle" it.
- mattkrause 10y ago"You" this particular function might not know how to handle it, but it's possible that some other part of the program does. To run with your example, I could imagine handling a missing storage device in lots of different ways, including a) Retry the operation b) Alert the user and block until a device (re)appears c) Switch to an alternative storage location d) Replace the to-be-read-in values with some sensible defaults. It seems to me that it would be easier to write this logic once and place it in an exception handler than it would be to wrap every I/O operation in a thicket of if/else clauses.