Symptom
Discovered by FsCheck fuzz property Fuzz_Try_Run_of_throwing_action_carries_message in the #170 batch:
Falsifiable, after 19 tests (0 shrinks):
---- System.ArgumentException : errorMessage cannot be null, empty, or whitespace. (Parameter 'errorMessage')
Repro
Result r = Try.Run(() => throw new InvalidOperationException(" "));
// throws System.ArgumentException instead of returning r.Failed == true
Cause
Try.Run(Action) (src/Wolfgang.TryPattern/Try.cs) catches every Exception and calls Result.Failure(ex.Message). Result.Failure (src/Wolfgang.TryPattern/Result.cs) requires a non-null, non-empty, non-whitespace error message and throws ArgumentException otherwise.
An exception whose Message is whitespace-only (or empty) makes Try.Run itself throw — defeating the whole point of the wrapper. Same failure mode applies to Try.Run<T>, Try.RunAsync, Try.RunAsync<T>.
Suggested fix
In the catch inside every Try.Run* overload, defensively coerce a whitespace / empty / null exception message to a fallback string before handing it to Result.Failure. Candidates:
ex.GetType().Name (e.g. "InvalidOperationException").
"<exception message was empty or whitespace>".
Scope note
This is exactly the class of edge-case the #170 fuzz workflow was designed to surface. The tightened property in that PR uses a generator that excludes whitespace so the fuzz suite ships clean while this bug is fixed separately.
Symptom
Discovered by FsCheck fuzz property
Fuzz_Try_Run_of_throwing_action_carries_messagein the #170 batch:Repro
Cause
Try.Run(Action)(src/Wolfgang.TryPattern/Try.cs) catches everyExceptionand callsResult.Failure(ex.Message).Result.Failure(src/Wolfgang.TryPattern/Result.cs) requires a non-null, non-empty, non-whitespace error message and throwsArgumentExceptionotherwise.An exception whose
Messageis whitespace-only (or empty) makesTry.Runitself throw — defeating the whole point of the wrapper. Same failure mode applies toTry.Run<T>,Try.RunAsync,Try.RunAsync<T>.Suggested fix
In the
catchinside everyTry.Run*overload, defensively coerce a whitespace / empty / null exception message to a fallback string before handing it toResult.Failure. Candidates:ex.GetType().Name(e.g."InvalidOperationException")."<exception message was empty or whitespace>".Scope note
This is exactly the class of edge-case the #170 fuzz workflow was designed to surface. The tightened property in that PR uses a generator that excludes whitespace so the fuzz suite ships clean while this bug is fixed separately.