Server SDK

Error monitoring for .NET

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.

Frameworks ASP.NET Core · plain .NETRequires .NET 8+Package Errorgap.AspNetCoreSource ↗Package ↗Agent guide ↗
Install

Install

sh
dotnet add package Errorgap.AspNetCore

For non-web apps, depend on Errorgap directly.

Configure

Configure

ASP.NET Core

In Program.cs, register the service and add the middleware first so it sees all downstream exceptions:

csharp
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();

Plain .NET

csharp
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.

Keep the key in an environment variable (or your framework's secret store) — never commit it to source control.
Trigger a test error

Trigger a test error

csharp
app.MapGet("/errorgap-test", () =>
{
    throw new InvalidOperationException("Errorgap test error");
});
Verify

Verify the connection

Confirm your key and endpoint reach errorgap before wiring anything else — send one event straight to the ingestion API:

bash
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.