ClinicianFOCUS / FreeScribe

A medical scribe capable of creating SOAP notes running Whisper and Kobold based on conversation with a patient
GNU General Public License v3.0
0 stars 0 forks source link

**issue:** Add error handling for numeric setting conversions #35

Open ItsSimko opened 1 day ago

ItsSimko commented 1 day ago
          **issue:** Add error handling for numeric setting conversions

The float() and int() conversions could raise ValueError if settings contain invalid values. Consider adding try/except blocks with appropriate error handling.

_Originally posted by @sourcery-ai[bot] in https://github.com/ClinicianFOCUS/FreeScribe/pull/33#discussion_r1825014447_

ItsSimko commented 1 day ago

Make it if one value fails only that one defaults instead of all of them

ItsSimko commented 1 day ago

from #34

The current implementation of numeric setting conversions in the codebase uses float() and int() functions. However, these conversions can raise a ValueError if the settings contain invalid values, such as non-numeric strings. This can lead to unhandled exceptions and potentially crash the application or lead to unexpected behavior.

To improve the robustness of the code, it is recommended to add error handling around these conversions. Implementing try/except blocks can catch these ValueError exceptions and allow the program to handle them gracefully, such as by logging an error message or setting a default value.

Action Items:

  1. Identify all instances where float() and int() conversions are used for settings.
  2. Wrap these conversions in try/except blocks.
  3. Decide on a strategy for handling the exceptions, such as logging the error or using a fallback value.
  4. Implement the changes and test to ensure that the application handles invalid settings without crashing.

I created this issue for @ItsSimko from #33 (comment).

Tips and commands