From 6d35129e239d164d3e0979ebfc1825b951278e6c Mon Sep 17 00:00:00 2001 From: CPD Date: Mon, 10 Mar 2025 12:20:29 +0100 Subject: [PATCH] Raise exception when led update fails --- cpdctrl/measurement.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cpdctrl/measurement.py b/cpdctrl/measurement.py index bdb08bc..94703ba 100644 --- a/cpdctrl/measurement.py +++ b/cpdctrl/measurement.py @@ -154,17 +154,18 @@ def measure( led_dev.set_level(new_led_val) led_val = new_led_val except Exception as e: - log.error("Error setting led to {new_led_val}%: {e}") + log.error(f"Error setting led to {new_led_val:03}%: {e}") + raise e except KeyboardInterrupt: - log.info("Keyboard interrupt, stopping") + log.info("Keyboard interrupt, stopping measurement") except Exception as e: - log.critical(f"Unexpected error, stopping. Error: {e}") + log.critical(f"Unexpected error, stopping measurement. Error: {e}") if add_measurement_info_to_metadata: data.metadata["measurement_time_stop"] = get_time() # Write again after having updated the stop time data.write_metadata() - data.flush(verbose=verbose) + data.flush() led_dev.off()