diff --git a/src/api_hooks.py b/src/api_hooks.py index efce6ee0..97dcf29c 100644 --- a/src/api_hooks.py +++ b/src/api_hooks.py @@ -404,9 +404,7 @@ class HookHandler(BaseHTTPRequestHandler): except (TypeError, ValueError): timeout = 30.0 controller = _get_app_attr(app, "controller", None) if controller and hasattr(controller, "wait_for_warmup"): - try: - controller.wait_for_warmup(timeout=timeout) - except Exception: pass + controller.wait_for_warmup(timeout=timeout) try: payload = controller.warmup_status() except Exception: @@ -450,7 +448,7 @@ class HookHandler(BaseHTTPRequestHandler): else: self.send_response(404) self.end_headers() - except Exception as e: + except (OSError, ValueError) as e: self.send_response(500) self.send_header("Content-Type", "application/json") self.end_headers() @@ -823,7 +821,7 @@ class HookHandler(BaseHTTPRequestHandler): else: self.send_response(404) self.end_headers() - except Exception as e: + except (OSError, ValueError) as e: import traceback traceback.print_exc(file=sys.stderr) self.send_response(500) diff --git a/src/file_cache.py b/src/file_cache.py index fc08b77d..7698e038 100644 --- a/src/file_cache.py +++ b/src/file_cache.py @@ -81,7 +81,7 @@ class ASTParser: try: p = Path(path) mtime = p.stat().st_mtime if p.exists() else 0.0 - except Exception: + except (OSError, ValueError): mtime = 0.0 if path in _ast_cache: diff --git a/src/orchestrator_pm.py b/src/orchestrator_pm.py index 2c788896..c556e17b 100644 --- a/src/orchestrator_pm.py +++ b/src/orchestrator_pm.py @@ -34,7 +34,7 @@ def get_track_history_summary() -> str: meta = json.load(f) title = meta.get("title", title) status = meta.get("status", status) - except Exception: + except (OSError, json.JSONDecodeError, UnicodeDecodeError): pass if spec_file.exists(): try: @@ -46,7 +46,7 @@ def get_track_history_summary() -> str: else: # Just take a snippet of the beginning overview = content[:200] + "..." - except Exception: + except (OSError, UnicodeDecodeError): pass summary_parts.append(f"Track: {title}\nStatus: {status}\nOverview: {overview}\n---") if not summary_parts: diff --git a/src/outline_tool.py b/src/outline_tool.py index 61a7829f..49cef487 100644 --- a/src/outline_tool.py +++ b/src/outline_tool.py @@ -87,7 +87,7 @@ class CodeOutliner: if getattr(node, "returns", None): try: returns = f" -> {ast.unparse(node.returns)}" - except Exception: + except (ValueError, TypeError): pass output.append(f"{' ' * indent}{prefix} {node.name}{returns} (Lines {start_line}-{end_line})") doc = get_docstring(node) @@ -106,7 +106,7 @@ class CodeOutliner: output.append(f"{' ' * indent}[ImGui Scope] {ctx_str} (Lines {start_line}-{end_line})") is_imgui = True break - except Exception: + except (ValueError, TypeError, AttributeError): pass for item in node.body: walk(item, indent + 1 if is_imgui else indent) diff --git a/src/shell_runner.py b/src/shell_runner.py index 4a9203da..4bf8e7e1 100644 --- a/src/shell_runner.py +++ b/src/shell_runner.py @@ -96,7 +96,7 @@ def run_powershell(script: str, base_dir: str, qa_callback: Optional[Callable[[s if 'process' in locals() and process: subprocess.run(["taskkill", "/F", "/T", "/PID", str(process.pid)], capture_output=True) raise - except Exception as e: + except (OSError, subprocess.SubprocessError) as e: if 'process' in locals() and process: subprocess.run(["taskkill", "/F", "/T", "/PID", str(process.pid)], capture_output=True) return f"ERROR: {e}" diff --git a/src/summarize.py b/src/summarize.py index 7742d984..d543af2f 100644 --- a/src/summarize.py +++ b/src/summarize.py @@ -180,11 +180,11 @@ def summarise_file(path: Path, content: str) -> str: summary = f"{smart_summary}\n\n**Outline:**\n{heuristic_outline}" else: summary = heuristic_outline - except Exception: + except (OSError, ValueError, TypeError, AttributeError): summary = heuristic_outline _summary_cache.set_summary(str(path), content_hash, summary) return summary - except Exception as e: + except (OSError, ValueError, TypeError) as e: return f"_Summariser error: {e}_" def summarise_items(file_items: list[dict[str, Any]]) -> list[dict[str, Any]]: