diff --git a/backend/code_parser.py b/backend/code_parser.py index 35b1765..ac1cb0f 100644 --- a/backend/code_parser.py +++ b/backend/code_parser.py @@ -23,6 +23,9 @@ def __init__(self, code): except SyntaxError as e: logging.error(f"SyntaxError: {e}") raise + except Exception as e: + logging.error(f"Unexpected error in CodeParser constructor: {e}") + raise def find_functions(self): return [node.name for node in ast.walk(self.tree) if isinstance(node, ast.FunctionDef)] @@ -65,6 +68,9 @@ def verify_database_connection(self): sample_code = "def example():\n return True" parser = CodeParser(sample_code) analysis = parser.analyze_code() - parser.save_analysis_to_db("sample_code.py", "Code Analysis", str(analysis), None) + try: + parser.save_analysis_to_db("sample_code.py", "Code Analysis", str(analysis), None) + except Exception as e: + logging.error(f"Unexpected error in save_analysis_to_db: {e}") parser.verify_database_connection() print(analysis) diff --git a/backend/pipeline_manager.py b/backend/pipeline_manager.py index 1d3a308..56f5504 100644 --- a/backend/pipeline_manager.py +++ b/backend/pipeline_manager.py @@ -25,6 +25,9 @@ def autogpt_task(self, task): max_tokens=150 ) return response.choices[0].text.strip() + except openai.error.AuthenticationError as e: + logging.error(f"API key error during autogpt_task: {e}") + return "API key error" except Exception as e: logging.error(f"Error during autogpt_task: {e}") return "" diff --git a/database/models.py b/database/models.py index 52cc02f..d731dd5 100644 --- a/database/models.py +++ b/database/models.py @@ -71,7 +71,7 @@ def verify_component_connections(): # Check modules components if not all([AlertsNotifications, APTSimulation]): - raise ValueError("Modules component connection check failed") + raise ValueError("Modules components connection check failed") logging.info("Modules components connection verified.") except Exception as e: