Middleware for ASP.NET Core that reports thrown exceptions and re-throws so your normal pipeline still renders the response. The core works anywhere, hooking unhandled and unobserved-task exceptions.
dotnet add package Errorgap.AspNetCoreFor non-web apps, depend on Errorgap directly.
In Program.cs, register the service and add the middleware first so it sees all downstream exceptions:
using Errorgap.AspNetCore;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddErrorgap(cfg =>
{
cfg.Endpoint = builder.Configuration["ERRORGAP_ENDPOINT"]!;
cfg.ProjectSlug = builder.Configuration["ERRORGAP_PROJECT_SLUG"]!;
cfg.ApiKey = builder.Configuration["ERRORGAP_API_KEY"];
});
var app = builder.Build();
app.UseErrorgap(); // first in the pipeline
app.Run();using Errorgap;
ErrorgapSdk.Init(new ErrorgapConfiguration
{
Endpoint = Environment.GetEnvironmentVariable("ERRORGAP_ENDPOINT")!,
ProjectSlug = Environment.GetEnvironmentVariable("ERRORGAP_PROJECT_SLUG")!,
ApiKey = Environment.GetEnvironmentVariable("ERRORGAP_API_KEY"),
});Init installs AppDomain.UnhandledException and TaskScheduler.UnobservedTaskException hooks.
app.MapGet("/errorgap-test", () =>
{
throw new InvalidOperationException("Errorgap test error");
});Confirm your key and endpoint reach errorgap before wiring anything else — send one event straight to the ingestion API:
curl -sS -X POST "$ERRORGAP_ENDPOINT/api/projects/$ERRORGAP_PROJECT_SLUG/notices" \
-H "content-type: application/json" \
-H "x-errorgap-project-key: $ERRORGAP_API_KEY" \
-d '{"errors":[{"type":"ErrorgapInstallTest","message":"Errorgap install verification"}]}'A 201 with a group_id means ingestion works (202 = received but sampled; 401 = wrong key). Then trigger the test error above through the SDK. Your onboarding screen's Verify step checks the stack off automatically once the first event lands — it polls every three seconds.
Next: the full ingestion API, or browse every SDK.