返回 Skill 列表
extension
分类: 开发与工程无需 API Key

Error Handling Auditor

查找并修复Leavn中的不安全错误处理 - try! 强制解包,空的catch块,静默的try? 失败

person作者: jakexiaohubgithub

Error Handling Auditor

Fix unsafe error handling:

  1. Find try! force unwraps: Replace with do-catch + fallback
  2. Find empty catch {}: Add AppLog.error("Context: \(error)")
  3. Find silent try?: Add logging for important failures

Patterns:

// Fix try!
do {
    result = try riskyOperation()
} catch {
    AppLog.error("Operation failed: \(error)")
    result = fallbackValue
}

// Fix empty catch
} catch {
    AppLog.error("Failed to save: \(error)", category: .persistence)
}

Use when: Crash risks, silent failures, debugging issues, error handling audit