+ 1
Very basic question: what does raising an exception do in the first place?
3 Respuestas
+ 2
You can raise an error when there's no actual error. Say you don't want the user to input a negative number in your code , you can raise an error message whenever the user does that and not allow it.
0
for example you can raise error for user to cant allow use a number.
0
Exception raising is a form of programming style/paradigm called event-driven programming. Say an event happens in your program (eg. a user specifies the wrong file name for opening a text file.) an exception can be raised for that event (FileNotFound) and some other code can handle the exception. It's most useful when you have to deal with a variety of cases of data which each has to be dealt with differently.