From 3d5515866fe16ed568b28236c2b15eeadbd241d6 Mon Sep 17 00:00:00 2001 From: pca006132 Date: Tue, 30 Jun 2020 17:25:44 +0800 Subject: [PATCH] Added artiq exception example --- examples/exception.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 examples/exception.py diff --git a/examples/exception.py b/examples/exception.py new file mode 100644 index 0000000..ec06741 --- /dev/null +++ b/examples/exception.py @@ -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") +