if not(my_value < max_limit):
print "value of is %g and hence invalid. It can be upto $g" % (my_value, max_limit)
raise LimitFailureCheck("Failed due to Incorrect value")
I have defined my custom exception as LimitFailureCheck
in other module. I want to raise it when my_value > max_limt. Hence I have coded like the above method. It works correctly. What I want to ask is to give user more info I have written print statement also which states what exactly the problem is. Can I do the same thing while raising my custom exception? I tried
raise LimitFailureCheck("Failed due to Incorrect %g value" % my_value)
But it raised the same statement when printed an output.
raise LimitFailureCheck("Failed due to Incorrect %g value" % my_value)
I was hoping to get
raise LimitFailureCheck("Failed due to Incorrect 99 value")
Output I received:
Traceback (most recent call last):
File "runtest.py", line 69, in attempt
func()
File "c:\Users\pran\projects\check.py", line 66, in runmytest
raise LimitFailureCheck('"Failed due to Incorrect %g value" % my_value
)
LimitFailureCheck