Secret ingredients to quality software


Do you use the best exception handling library?

Last updated by Tiago Araújo [SSW] on 26 Apr 2021 10:27 pm (10 days ago) See History

When developing software, exceptions are a fact-of-life you will need to deal with. Don't reinvent the wheel, use an existing exception handling library or service.

The best exception handling service is Application Insights for Visual Studio Online, but if you can't use that, then use

Your users should never see the “yellow screen of death” in ASP.NET, or the “unhandled exception” message in a Windows application. Errors should always be caught and logged – preferably in a SQL database. As developers you should be alerted when something is going wrong and be able to see details to help you track down and fix bugs.

default asp error 500 small
If you see this, you are doing something wrong!

At SSW we use Application Insights where possible. If you are still developing Windows applications, then you can still use Application Insights, read here for more details.

Application Insights will tell you if your application goes down or runs slowly under load. If there are any uncaught exceptions, you’ll be able to drill into the code to pinpoint the problem. You can also find out what your users are doing with the application so that you can tune it to their needs in each development cycle.

If Application Insights is not available we use Seq when developing web applications. From its page:

Seq is built for modern structured logging with message templates. Rather than waste time and effort trying to extract data from plain-text logs with fragile log parsing, the properties associated with each log event are captured and sent to Seq in a clean JSON format. Message templates are supported natively by ASP.NET Core, Serilog, NLog, and many other libraries, so your application can use the best available diagnostic logging for your platform.

Application Insights gives you very useful graphs and analysis which give you a good overview of how things are going. See here for more details. Seq is great for identifying specific issues and how to fix them, but is not as good at letting you see the big picture.

xn4QHnmBS0Kx39gOv0wM GettingStarted 1
Seq provides you with plenty of details about what is happening, but if you don't already know what you're looking for, it can be tricky to parse

Application Insights gives you graphs and analysis that help you find issues, but also lets you drill down to get the details as well

Related Rules

    Adam CoganAdam Cogan
    Drew RobsonDrew Robson

    We open source. This page is on GitHub