blazorfast-endpoints

Fast Endpoints DontCatchExceptions(); not working


I am using Fast Endpoints in a .net8 Blazor Web App API. I am putting

DontCatchExceptions();

in some of the Configure methods like this:

Post("policies/contacts");
Options(x => x.WithTags("Policy"));
DontCatchExceptions();

and the HandleAsync method throws the error:'

  public override async Task HandleAsync(CancellationToken ct)
  {
    try
    {
      var list = await Data.GetCountryCodeList();

      await SendAsync(list);
    }
    catch (Exception e)
    {
      ThrowError(e.Message, 400);
    }
  }

So far I've only use it in GET methods and it's worked fine. Now I'm using it in a POST method, but it doesn't work. It's just ignored - no error or anything. I don't know if it's because it's a POST method, that's just the only obvious difference I see. I put a breakpoint on the ThrowError line and it's hitting there.


Solution

  • I left this for a while and came back. I reinstalled the nuget package and it worked. I hate when that happens! Sending the response to the client is what I was trying to do.

    Thank you