OpenwaterHealth / OpenwaterHealth/openlifu-python

Improve Exception handling in sonication control

Open
#227 0 comments 1 reaction 1 assignee View on GitHub

@peterhollender is already working on this.

Since Mar 3, 2025.

Dominant language
Python
Stars
27
Forks
21
Avg merge
1d 20m
Merged PRs (30d)
6

Description

Currently, the io module (LIFUInterface, LIFUTXDevice, etc) use a number of try... except cases to catch both UART errors and log other exceptions. There are a couple of issues with the way this is handled:

  1. We are raising ValueErrors when the communications are failing. This should probably be something more specific if we would like to catch it and print a more detailed Exception message
  2. We are checking for UART connectivity in each method using a very similar snippet of code - this should probably me a method.
  3. We are catching all other Exceptions, and logging the error before re-raising it. I think that this is unnecessary, as we can configure the logger to capture the stdout output from unhandled exceptions

I'll work on tidying this up.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.