Skip to content

Code Quality: Exception swallowing without logging despite comment claiming 'Log' #68

@sfloess

Description

@sfloess

Problem

ClaudeService.clearHistory() catches exceptions with a comment saying "Log but don't rethrow" but contains NO actual logging code. The exception is completely lost.

Evidence

ClaudeService.java lines 137-142:

public void clearHistory() {
    try {
        client.clearHistory();
    } catch (Exception e) {
        // Log but don't rethrow - gracefully handle clearing history
        // ^^^ COMMENT SAYS "LOG" BUT NO LOGGER.log() CALL EXISTS
    }
}

ClaudeClient.clearHistory() now throws ClaudeException:

public void clearHistory() throws ClaudeException {
    synchronized (this) {
        if (closed) {
            throw new ClaudeException("Client has been closed");
        }
        conversationHistory.clear();
    }
}

No logger defined in ClaudeService:

  • No LOGGER field exists in the class
  • No logger import in the file

Impact

User calls service.clearHistory() → 
client.clearHistory() throws ClaudeException('Client has been closed') → 
Exception caught and silently discarded (no logging) → 
User has no indication operation failed → 
User believes history was cleared when it wasn't → 
Continues using service with stale history

Debugging Impact:

  • Silent failures make debugging difficult
  • No way to know clearHistory() failed without checking history size
  • Violates principle of least surprise - method appears to succeed but fails silently

Recommendation

Option 1 - Add actual logging:

private static final Logger LOGGER = Logger.getLogger(ClaudeService.class.getName());

public void clearHistory() {
    try {
        client.clearHistory();
    } catch (Exception e) {
        LOGGER.log(Level.WARNING, "Failed to clear conversation history", e);
        // Don't rethrow - gracefully handle clearing history
    }
}

Option 2 - Don't catch, let it propagate:

public void clearHistory() throws ClaudeException {
    client.clearHistory();
}

Location


Detected by AI-assisted code review on 2026-06-05 (iteration 3)

Metadata

Metadata

Assignees

No one assigned

    Labels

    ai-modulesAffects AI modulescode-qualityCode quality improvementmediumMedium priority - nice to have

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions