Skip to content

Conversation

XxAlonexX
Copy link

Description

This PR improves error handling and logging in the simulation control module (control.py). The changes focus on providing better error messages, comprehensive logging, and robust exception handling to make debugging and troubleshooting easier.

Changes Made

  1. Simulation Begin Method:

    • Added comprehensive try-catch block
    • Added specific handling for ImportError
    • Improved error messages and logging at multiple levels
    • Enhanced docstring with exception information
  2. Simulation End Method:

    • Added try-catch block for better error handling
    • Added success and failure logging
    • Improved error messages to be more descriptive
    • Updated docstring with exception details
  3. Add Agent Method:

    • Added validation for None values
    • Added specific handling for AttributeError
    • Improved error messages for duplicate agent names
    • Added success logging for agent addition
    • Enhanced docstring with parameters and exceptions

Testing

The changes maintain existing functionality while adding better error reporting. The following scenarios have been tested:

  • Starting an already started simulation
  • Ending an already stopped simulation
  • Adding an agent with a duplicate name
  • Adding an invalid agent (None)
  • Adding an agent without a name attribute

Benefits

  1. Better Debugging: More detailed error messages and logging make it easier to identify issues
  2. Improved Reliability: Additional validation prevents invalid states
  3. Better Documentation: Updated docstrings provide clearer guidance on method usage

Related Issues

Addresses the need for better error handling and logging in simulation control operations.

@XxAlonexX
Copy link
Author

@microsoft-github-policy-service agree

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.

1 participant