kuroko/test/testTryExcept.krk

30 lines
753 B
Python
Raw Permalink Normal View History

print("Hello, world!")
2020-12-29 05:00:12 +03:00
try:
print("This is the try block")
2020-12-29 05:00:12 +03:00
let f = 123
print(f)
print("Blah blah blah")
print("Oh no let's raise an exception!")
2020-12-29 05:00:12 +03:00
raise "oh no!"
print("This should not print")
print("Instead we should jump to the except block")
2020-12-29 05:00:12 +03:00
except:
print("This is the except block")
2020-12-29 05:00:12 +03:00
let j = 456
print(j)
print("This is outside of the try-except")
2020-12-29 05:00:12 +03:00
print("Let's try nesting an exception and raising it")
2020-12-29 05:00:12 +03:00
try:
print("This is the top level")
2020-12-29 05:00:12 +03:00
try:
print("This is the inner level")
2020-12-29 05:00:12 +03:00
raise "This is the exception"
except as exception:
print("This is the inner handler.")
2020-12-29 05:00:12 +03:00
raise exception
except as exception:
print("This is the outer handler.")
print(exception)