0

When is exception raise useful?

8th Mar 2017, 3:37 AM
Jing Luo
2 Respostas
+ 2
when we cant understand which exception is occurs...
8th Mar 2017, 3:39 AM
Mayur Chaudhari
Mayur Chaudhari - avatar
+ 1
You can and should raise an exception when you think something could go wrong with the execution of the code, example: reading user input, the user might purposely enter incorrect data causing the program to crash, if you have exception for this then instead of the program crashing, an error can be raised and the program will continue. lets say I want to read data from a DB and store the information in a object, now we don't have to worry about users errors, but what if the server is down, that will also crash the program, so exceptions can be raised here as well.
8th Mar 2017, 3:51 AM
Elfren Authorlee
Elfren Authorlee - avatar