Skip to main content
QUICK REVIEW

[论文解读] CatchAll: Repository-Aware Exception Handling with Knowledge-Guided LLMs

Qingxiao Tao, Xiaodong Gu|arXiv (Cornell University)|Jan 3, 2026
Software Engineering ResearchComputer Science被引用 0
一句话总结

CATCHALL 通过利用来自 API、执行上下文和跨仓库模式的知识,增强基于大模型的异常处理,并在新的 RepoExEval 基准上显示出优于基线的性能。

ABSTRACT

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.

研究动机与目标

  • 推动自动化、鲁棒的异常处理,利用仓库上下文来改进恢复动作。
  • 引入三层知识增强(API 级、仓库级执行上下文、跨仓库处理模式)。
  • 自动挖掘真实世界的代码仓库,构建高质量的异常处理知识。
  • 使用新数据集 RepoExEval 与 RepoExEval-Exec 基准对仓库感知异常处理进行基准测试。
  • 在多项指标上展示优于现有最先进基线的性能。

提出的方法

  • 从大型代码仓库的真实 try-catch 块中挖掘 API–异常映射。
  • 通过多文件、跨方法调用轨迹构建仓库感知的执行上下文,深度为 d。
  • 基于 API–异常映射的检索增强生成(RAG)框架来预测潜在异常类型。
  • 检索前-K 个相似的历史 try-catch 块并抽象可重复使用的处理模式。
  • 通过将生成的代码块置于上下文轨迹与模式中进行锚定,实例化并定制异常处理代码。

实验结果

研究问题

  • RQ1RQ1: CATCHALL 如何在仓库感知的异常处理上提升到最先进水平。
  • RQ2RQ2: 预测的异常类型有多准确。
  • RQ3RQ3: 单个知识组件的影响有哪些。
  • RQ4RQ4: 检索的历史样本数量如何影响结果。

主要发现

  • CATCHALL 在 CodeBLEU 上优于基线(最佳基线为 0.27%,CATCHALL 为 0.31%)。
  • 意图预测的准确率达到 60.1%,高于竞争基线的 48.0%。
  • Pass@1 提升到 29%,相比最佳竞争对手的 25%。
  • 在多种骨干模型(GPT-4o 与 DeepSeek-V3)下,CATCHALL 显示出持续的改进。
  • 该方法在仓库感知的异常处理任务中展现出显著的收益。
  • 引入 RepoExEval 与 RepoExEval-Exec 基准,用于评估仓库级处理。

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。