title: Unit Testing a "Catch" in C#
body: <p>I have created an API project using .NET 6.0.
  I have configured the app.MapGet method correctly, and they are executing their respective methods.
  These methods execute their respective Datacalls and return &quot;Results.Ok(results)&quot;</p>
  <pre><code>   public static class ResultSetBeingReturned
  {
      public static async Task&lt;IResult&gt; ExecuteResultSet&lt;T&gt;(this Task&lt;IEnumerable&lt;T&gt;&gt; task)
      {
          try
          {
              var results = await task;
  
              if (results == null) return Results.NotFound();
  
              return Results.Ok(results);
          }
          catch (Exception ex)
          {
  
              return Results.Problem(ex.Message);
          }
      }
  }
  </code></pre>
  <p>I want to unit test this method, so my question is: How do I invoke an API that is going to generate an Exception that is NOT a 404 Not Found?</p>