← All platforms

.NET error tracking

A console app can have a bad day, too. The Sentry .NET SDK sends its exceptions to Telebugs, where the reports stay on your server.

~/hoofnotes  dotnet add package Sentry
~/hoofnotes  nvim Program.cs
using Sentry;
using (SentrySdk.Init(options =>
{
// Copy the complete Telebugs DSN, key and path included.
options.Dsn = "YOUR_TELEBUGS_DSN";
}))
{
try
{
throw new InvalidOperationException("Hello from Hoof Notes");
}
catch (Exception error)
{
SentrySdk.CaptureException(error);
}
}
~/hoofnotes  dotnet run

Space pauses or resumes. R replays. Escape shows the complete setup.

Hang on, I already use Sentry

Keep Sentry. Point it at your Telebugs DSN and keep reporting errors as before. The reports go to your server; you don’t need a Sentry account.

What if I catch the exception?

You can handle it and still keep a report. Call SentrySdk.CaptureException from your catch block. Unhandled managed exceptions have their own SDK hook.

And for a web app?

Use the ASP.NET Core integration. It adds request error handling, so a failed endpoint leaves you more than an HTTP status code.