In real world software development, improper or missing exception handling can severely impact the robustness and reliability of code. Exception handling mechanisms require developers to detect, capture, and manage exceptions according to high standards, but many developers struggle with these tasks, leading to fragile code. This problem is particularly evident in open-source projects and impacts the overall quality of the software ecosystem. To address this challenge, we explore the use of large language models (LLMs) to improve exception handling in code. Through extensive analysis, we identify three key issues: Insensitive Detection of Fragile Code, Inaccurate Capture of Exception Block, and Distorted Handling Solution. These problems are widespread across real world repositories, suggesting that robust exception handling practices are often overlooked or mishandled. In response, we propose Seeker, a multi-agent framework inspired by expert developer strategies for exception handling. Seeker uses agents: Scanner, Detector, Predator, Ranker, and Handler to assist LLMs in detecting, capturing, and resolving exceptions more effectively. Our work is the first systematic study on leveraging LLMs to enhance exception handling practices in real development scenarios, providing valuable insights for future improvements in code reliability.
翻译:在现实世界的软件开发中,不当或缺失的异常处理会严重影响代码的健壮性和可靠性。异常处理机制要求开发者按照高标准检测、捕获和管理异常,但许多开发者难以胜任这些任务,导致代码脆弱。这一问题在开源项目中尤为明显,并影响了软件生态系统的整体质量。为应对这一挑战,我们探索利用大语言模型(LLMs)来改进代码中的异常处理。通过广泛分析,我们识别出三个关键问题:脆弱代码的感知不足、异常块捕获不准确以及处理方案扭曲。这些问题在现实代码库中普遍存在,表明健壮的异常处理实践常被忽视或处理不当。为此,我们提出Seeker,一个受专业开发者异常处理策略启发的多智能体框架。Seeker利用Scanner、Detector、Predator、Ranker和Handler等智能体,协助LLMs更有效地检测、捕获和解决异常。我们的工作是首个系统性地利用LLMs增强实际开发场景中异常处理实践的研究,为未来提升代码可靠性提供了宝贵见解。