Flezi AgentBox
All Use Cases

Error Handling Audit — Error Auditor

Find ignored errors, missing returns, and panics without recover across your codebase

Error Handling Audit Agent

The Problem

Go returns errors as values, and it is dangerously easy to ignore them with _. Silent failures cascade: a failed DB write returns no error, the handler sends 200 OK, and the user thinks their data is saved. Panics without recover crash entire servers. These bugs hide in plain sight and only surface as data loss in production.

The Solution

Error Auditor scans every function call, finds every ignored error, missing error return, and unrecovered panic. It generates the correct if err != nil blocks with proper wrapping and context — turning silent failures into explicit, debuggable errors.

How It Works

Before Agent

Developer writes code → suppresses error with _ → code compiles fine → 
tests pass (no error assertions) → deploys → user data silently lost → 
support ticket filed 3 days later → developer traces through logs → 
finds swallowed error (6+ hours to diagnose)

After Agent

Developer writes code → runs error-auditor → finds 15 ignored errors 
in 3 seconds → generates if err != nil blocks with context → 
developer applies fixes → all errors now logged and returned 
(5 minutes total)

What It Catches

  • ✅ Ignored Errors — result, _ := db.Query() patterns
  • ✅ Missing Error Returns — functions that check error but don't return it
  • ✅ Panic Without Recover — goroutines lacking defer/recover
  • ✅ Bare Error Returns — return err without wrapping or context
  • ✅ Nil Pointer Risks — unchecked return values used immediately
  • ✅ Lost Error Context — fmt.Errorf without %w verb
  • ✅ Empty Catch Blocks — catch (e) {} in TypeScript/JavaScript
  • ✅ Swallowed Promises — async calls without await or .catch()
  • ✅ Missing Cleanup — errors returned before defer/close
  • ✅ Unreachable Error Handlers — dead code after early returns

Real Example

Input (Go code with silent failures):

go
func SaveUser(u User) {
  result, _ := db.Exec("INSERT INTO users (name, email) VALUES ($1, $2)", u.Name, u.Email)
  _ = cache.Set("user:"+u.ID, u, time.Hour)
  
  go func() {
    sendWelcomeEmail(u.Email)
  }()
  
  log.Printf("User saved: %s", u.Name)
}

Agent Output:

🔴 CRITICAL: Ignored error from db.Exec (line 2)
   Data may silently fail to save
   Fix:
   result, err := db.Exec("INSERT INTO users ...")
   if err != nil {
     return fmt.Errorf("save user %s: %w", u.Name, err)
   }

🟡 WARNING: Ignored error from cache.Set (line 3)
   Fix: log cache error, don't fail the request
   if err := cache.Set(...); err != nil {
     log.Warn("cache set failed", "err", err)
   }

🔴 CRITICAL: Goroutine without recover (line 5-7)
   Panic in sendWelcomeEmail will crash the server
   Fix:
   go func() {
     defer func() {
       if r := recover(); r != nil {
         log.Error("email panic", "err", r)
       }
     }()
     sendWelcomeEmail(u.Email)
   }()

Found: 3 issues (2 critical, 1 warning) in SaveUser

Impact Numbers

| Metric | Before | After | |--------|--------|-------| | Silent failures per file | 10-15 average | 0 | | Data loss incidents/month | 2-4 | 0 | | Time to diagnose error bugs | 2-6 hours | Prevented entirely | | Error context in logs | Minimal | Full stack with wrapping | | Panic crashes/month | 1-3 | 0 |

Getting Started

bash
agentbox pull error-auditor
agentbox error-auditor "audit error handling"

Related Use Cases