find-exception-issues
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "find-exception-issues":https://skillpi.com/zh/skills/deepskill-7748e2199428ac4a2170b67c980c75ca16ffacd7085bac3921302db2c85233b4。安装前核对上游来源和版本:https://github.com/dykyi-roman/awesome-claude-code。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
检测 PHP 代码中的异常处理问题,包括吞没异常、过于通用的捕获、缺少异常处理、重新抛出时未添加上下文以及在 finally 块中抛出异常等问题。
介绍来源: third_party · dykyi-roman · 0.0.1 参考来源
SkillPi 解读
- 能完成的任务
- 翻译待完成,请参阅来源文档。
- 输入和输出
- 减记
- 实测状态
- 未测试
文件浏览
Frontmatter
name: find-exception-issues
description: Detects exception handling issues in PHP code. Finds swallowed exceptions, generic catches, missing exception handling, re-throwing without context, exception in finally.Exception Issue Detection
Analyze PHP code for exception handling problems.
Detection Patterns
1. Swallowed Exceptions (Empty Catch)
// BUG: Exception completely ignored
try {
$this->riskyOperation();
} catch (Exception $e) {
// Empty catch block - bug hidden
}
// BUG: Only logging, no handling
try {
$this->process();
} catch (Exception $e) {
$this->logger->error($e->getMessage());
// No re-throw, no return, execution continues
}
2. Generic Exception Catching
// BUG: Catches everything
try {
$this->save();
} catch (Exception $e) {
// Catches TypeError, LogicException, etc.
}
// BUG: Using Throwable carelessly
try {
$this->process();
} catch (Throwable $t) {
// Catches Error too, hiding fatal issues
}
3. Missing Exception Handling
// BUG: Unchecked external call
$response = $httpClient->request('GET', $url); // May throw
// BUG: File operations without try
$content = file_get_contents($path); // Returns false on failure
// BUG: JSON without error check
$data = json_decode($json); // May return null on error
4. Re-throwing Without Context
// BUG: Lost context
try {
$this->process();
} catch (DatabaseException $e) {
throw new RuntimeException('Failed'); // Lost original exception
}
// FIXED: Preserve chain
throw new RuntimeException('Failed to process', 0, $e);
5. Exception in Finally Block
// BUG: Exception in finally hides original
try {
$this->process();
} finally {
$this->cleanup(); // If this throws, original exception is lost
}
// FIXED:
} finally {
try {
$this->cleanup();
} catch (Exception $e) {
$this->logger->warning('Cleanup failed', ['exception' => $e]);
}
}
6. Catch Order Issues
// BUG: Parent before child
try {
$this->process();
} catch (Exception $e) {
// Catches everything
} catch (InvalidArgumentException $e) {
// Never reached
}
7. Return in Finally
// BUG: Return in finally overrides exception
try {
throw new Exception('Error');
} finally {
return true; // Exception is suppressed
}
8. Using Exception for Control Flow
// BUG: Exception as goto
try {
foreach ($items as $item) {
if ($found) {
throw new FoundException($item);
}
}
} catch (FoundException $e) {
$result = $e->getItem();
}
9. Missing @throws Documentation
// BUG: Undocumented exception
public function process(): void
{
if (!$valid) {
throw new InvalidArgumentException(); // Not documented
}
}
Grep Patterns
# Empty catch blocks
Grep: "catch\s*\([^)]+\)\s*\{\s*\}" --glob "**/*.php"
# Generic Exception catch
Grep: "catch\s*\(\s*(Exception|\\\\Exception)\s+" --glob "**/*.php"
# Throwable catch
Grep: "catch\s*\(\s*(Throwable|\\\\Throwable)\s+" --glob "**/*.php"
# throw new without previous
Grep: "throw new \w+Exception\([^,)]+\);" --glob "**/*.php"
# Return in finally
Grep: "finally\s*\{[^}]*return" --glob "**/*.php"
Severity Classification
| Pattern | Severity |
|---|---|
| Swallowed exception | 🔴 Critical |
| Return in finally | 🔴 Critical |
| Generic Throwable catch | 🟠 Major |
| Lost exception chain | 🟠 Major |
| Exception for control flow | 🟡 Minor |
| Missing @throws | 🟡 Minor |
Best Practices
Specific Exception Handling
try {
$this->save();
} catch (UniqueConstraintException $e) {
throw new DuplicateEmailException($email, 0, $e);
} catch (ConnectionException $e) {
throw new DatabaseUnavailableException(0, $e);
}
// Let other exceptions bubble up
Proper Exception Chain
throw new DomainException(
sprintf('Failed to process order %s', $orderId),
previous: $originalException
);
Safe Finally
try {
$this->process();
} finally {
try {
$this->cleanup();
} catch (Throwable $e) {
// Log but don't throw
$this->logger->error('Cleanup failed', ['exception' => $e]);
}
}
Output Format
### Exception Issue: [Description]
**Severity:** 🔴/🟠/🟡
**Location:** `file.php:line`
**Type:** [Swallowed|Generic Catch|Missing Chain|...]
**Issue:**
[Description of the exception handling problem]
**Code:**
```php
// Problematic code
Fix:
// Proper exception handling
当前收录版本
0.0.1
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 提供 PHP 代码异常处理的检测能力,解决开发者常见痛点
- 覆盖多种异常处理问题类型,具备明确实用价值
亮点
- 触发词精准完整,明确描述检测 PHP 异常处理问题的功能
- 列举具体问题类型,边界清晰,便于用户理解适用场景
待提升项
-
缺少 When to Use 章节 原报告严重程度:轻微
文档结构完整,但缺少明确的'When to Use'使用场景说明章节
改进建议:建议添加'When to Use'章节,说明何时使用此 Skill 最为合适
-
文档较长 原报告严重程度:轻微
文档内容较为详尽,总行数较多,可能影响阅读体验
改进建议:可考虑将部分内容折叠或拆分为多个子章节,提升可读性
亮点
- 文档结构清晰,包含检测模式、grep 命令、严重性分级等完整内容
- 提供丰富的代码示例和最佳实践,便于理解与执行
亮点
- 提供具体的 grep 命令模式,便于直接执行检测
- 对不同问题类型进行严重性分级,提升执行指导价值
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。