Skip to content

Improve error handling specificity #33

Description

@Ofido

Description

Some except Exception blocks in the code could be more specific. Catching specific exceptions makes the code more robust and easier to debug.

Example

        except Exception as e:
            self.logger.error(f"Workflow failed: {e}", exc_info=True)
            return {
                "status": "error",
                "error": str(e),
                "workflow_duration_seconds": asyncio.get_event_loop().time() - workflow_start_time,
            }

Suggested Improvement

Instead of catching the generic Exception, we should catch more specific exceptions, such as ConfigurationError, LLMConnectionError, etc.

        except ConfigurationError as e:
            self.logger.error(f"Configuration failed: {e}", exc_info=True)
            return {
                "status": "error",
                "error": f"Configuration error: {e}",
                "workflow_duration_seconds": asyncio.get_event_loop().time() - workflow_start_time,
            }
        except LLMConnectionError as e:
            self.logger.error(f"LLM connection failed: {e}", exc_info=True)
            return {
                "status": "error",
                "error": f"LLM connection error: {e}",
                "workflow_duration_seconds": asyncio.get_event_loop().time() - workflow_start_time,
            }
        except Exception as e:
            self.logger.error(f"An unexpected error occurred: {e}", exc_info=True)
            return {
                "status": "error",
                "error": f"An unexpected error occurred: {e}",
                "workflow_duration_seconds": asyncio.get_event_loop().time() - workflow_start_time,
            }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions