The template:
#import traceback
#try
#raise RuntimeError
#except RuntimeError
A runtime error occurred.
#end try
#try
#raise RuntimeError("Hahaha!")
#except RuntimeError
#echo $sys.exc_info()[1]
#end try
#try
#echo 1/0
#except ZeroDivisionError
You can't divide by zero, idiot!
#end try
The output:
A runtime error occurred. Hahaha! You can't divide by zero, idiot!
The generated code:
try:
raise RuntimeError
except RuntimeError:
write('A runtime error occurred.\n')
write('\n')
try:
raise RuntimeError("Hahaha!")
except RuntimeError:
write(filter(VFN(sys,"exc_info",0)()[1]))
write('\n')
write('\n')
try:
write(filter(1/0))
write('\n')
except ZeroDivisionError:
write("You can't divide by zero, idiot!\n")
#finally works just like in Python.