Skip to content

Conversation

@sjefferson99
Copy link
Member

…ately

@sjefferson99 sjefferson99 self-assigned this Oct 27, 2025
@sjefferson99 sjefferson99 linked an issue Oct 27, 2025 that may be closed by this pull request
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds error handling to the sensor polling loop to prevent crashes and ensure continuous operation. The changes wrap the polling logic in a try-except block that logs errors when they occur.

Key changes:

  • Added try-except block around sensor polling operations to catch and log exceptions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

else:
self.log.error("No sensor readings available")
except Exception as e:
self.log.error(f"Error in sensor polling cycle: {e}")
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Catching broad Exception can mask critical errors like KeyboardInterrupt or SystemExit. Consider catching more specific exceptions or using except Exception: with explicit re-raising of critical exceptions. Additionally, consider logging the full stack trace using self.log.exception() instead of self.log.error() to aid debugging.

Suggested change
self.log.error(f"Error in sensor polling cycle: {e}")
# Re-raise critical exceptions and log full stack trace for others
if isinstance(e, (KeyboardInterrupt, SystemExit)):
raise
self.log.exception(f"Error in sensor polling cycle: {e}")

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sensor data failed to push to SMIB for 3 days silently

1 participant