Added artiq exception example

This commit is contained in:
pca006132 2020-06-30 17:25:44 +08:00
parent eb750eb1f0
commit 3d5515866f
1 changed files with 20 additions and 0 deletions

20
examples/exception.py Normal file
View File

@ -0,0 +1,20 @@
from artiq.experiment import *
class ExceptionDemo(EnvExperiment):
def build(self):
self.setattr_device("core")
self.setattr_device("led0")
@kernel
def run(self):
self.core.reset()
print("OK!")
try:
try:
raise Exception
except ValueError as e:
print("re-raise")
raise e
except:
print("error")