🔧 Fix a Tuple Deconstruction Hiding a Discarded Exception
A method that returns a value tuple paired with a ‘try’ style boolean ((bool Success, T Value)) is a common pattern for avoiding exceptions on the happy path, but deconstructing straight into two variables and only checking the boolean means any exception the inner implementation swallowed to produce that boolean in the first place is gone for good — there’s no stack trace, no message, nothing left to debug once the call site only sees (false, default).
🔎 The Problem
public (bool Success, Config Value) TryLoad(string path)
{
try { return (true, Parse(File.ReadAllText(path))); }
catch { return (false, default); } // original exception discarded
}
var (ok, cfg) = TryLoad(path);
if (!ok) { Log("Load failed"); } // no idea WHY it failed
✅ Fix: Carry the Failure Reason Through, Not Just a Boolean
- Extend the tuple to include the caught exception or a message (
(bool Success, T Value, Exception? Error)) so the call site can log or inspect the real cause instead of a bare false. - At minimum, log the caught exception at the point it’s caught, even if the public-facing method still only returns a boolean to its caller — that preserves the diagnostic information somewhere.
- Reserve the ‘try’ tuple pattern for genuinely expected failure cases (file not found, parse error) and let truly unexpected exceptions propagate normally, so a silent catch-all doesn’t end up hiding bugs that should have been loud.
A boolean can tell you that something failed — it can’t tell you why, and the exception that knew why is already gone.




