[Paper Review] CatchAll: Repository-Aware Exception Handling with Knowledge-Guided LLMs
CATCHALL augments LLM-based exception handling with repository-aware knowledge from APIs, execution contexts, and cross-repository patterns, and evaluates on new RepoExEval benchmarks showing superior performance over baselines.
Exception handling is a vital forward error-recovery mechanism in many programming languages, enabling developers to manage runtime anomalies through structured constructs (e.g., try-catch blocks). Improper or missing exception handling often leads to severe consequences, including system crashes and resource leaks. While large language models (LLMs) have demonstrated strong capabilities in code generation, they struggle with exception handling at the repository level, due to complex dependencies and contextual constraints. In this work, we propose CatchAll, a novel LLM-based approach for repository-aware exception handling. CatchAll equips LLMs with three complementary layers of exception-handling knowledge: (1) API-level exception knowledge, obtained from an empirically constructed API-exception mapping that characterizes the exception-throwing behaviors of APIs in real-world codebases; (2) repository-level execution context, which captures exception propagation by modeling contextual call traces around the target code; and (3) cross-repository handling knowledge, distilled from reusable exception-handling patterns mined from historical code across projects. The knowledge is encoded into structured prompts to guide the LLM in generating accurate and context-aware exception-handling code. To evaluate CatchAll, we construct two new benchmarks for repository-aware exception handling: a large-scale dataset RepoExEval and an executable subset RepoExEval-Exec. Experiments demonstrate that RepoExEval consistently outperforms state-of-the-art baselines, achieving a CodeBLEU score of 0.31 (vs. 0.27% for the best baseline), intent prediction accuracy of 60.1% (vs. 48.0%), and Pass@1 of 29% (vs. 25%). These results affirm RepoExEval's effectiveness in real-world repository-level exception handling.
Motivation & Objective
- Motivate automated, robust exception handling that leverages repository context to improve recovery actions.
- Introduce three-layer knowledge augmentation (API-level, repository-level execution context, cross-repository handling patterns).
- Automatically mine real-world code repositories to build high-quality exception-handling knowledge.
- Benchmark repository-aware exception handling using new datasets RepoExEval and RepoExEval-Exec.
- Demonstrate superior performance against state-of-the-art baselines across multiple metrics.
Proposed method
- Mine API–exception mappings from real-world try-catch blocks across large code repositories.
- Construct repository-aware execution context via multi-file, cross-method call traces up to a depth d.
- Predict potential exception types using a retrieval-augmented generation (RAG) framework grounded in API-exception mappings.
- Retrieve top-K similar historical try-catch blocks and abstract reusable handling patterns.
- Instantiate and tailor exception-handling code by grounding generated blocks in contextual traces and patterns.
Experimental results
Research questions
- RQ1RQ1: How does CATCHALL improve state-of-the-art performance in repository-aware exception handling.
- RQ2RQ2: How accurate are the predicted exception types.
- RQ3RQ3: What are the impacts of individual knowledge components.
- RQ4RQ4: How does the number of retrieved historical samples affect results.
Key findings
- CATCHALL outperforms baselines on CodeBLEU (0.31 vs. 0.27% for best baseline).
- Intent prediction accuracy reaches 60.1% versus 48.0% for a competitive baseline.
- Pass@1 improves to 29% compared with 25% for the best competitor.
- Across multiple backbones (GPT-4o and DeepSeek-V3), CATCHALL shows consistent improvements.
- The approach demonstrates strong gains in repository-aware exception handling tasks.
- Benchmarks RepoExEval and RepoExEval-Exec are introduced to evaluate repository-level handling.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.