+ 1

Very basic question: what does raising an exception do in the first place?

25th Dec 2015, 8:03 PM
Kasia Kulma
Kasia Kulma - avatar
3 Answers
+ 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.
30th Dec 2015, 7:22 AM
EUREKA - avatar
for example you can raise error for user to cant allow use a number.
22nd Feb 2016, 5:37 PM
Amirmahdi Kalbasi
Amirmahdi Kalbasi - avatar
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.
13th Apr 2016, 3:53 PM
Xaeros - avatar