Skip to content

Don't silently swallow errors in TryGetAsync #43

Description

@matthewdevenny

Problem

NatsCache.TryGetAsync(string, IBufferWriter<byte>, …) catches all exceptions and returns false with no logging (src/NatsDistributedCache/NatsCache.cs). A NATS connectivity error is then indistinguishable from a normal cache miss and leaves no diagnostic trail.

catch
{
    // Ignore failures here; they will surface later
}

Proposal

Log the swallowed exception at debug/trace (reusing the existing Exception event id) before returning false. Keep returning false so the IBufferDistributedCache contract is preserved.

Acceptance criteria

  • A thrown error in the buffer read path produces a log entry.
  • Return behavior is otherwise unchanged.

Good first issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    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