Click here to Skip to main content
13,354,605 members (65,337 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


10 bookmarked
Posted 19 May 2014

How to use exceptions to your advantage with Quilt4Net

, 20 May 2014
Rate this:
Please Sign up or sign in to vote.
What do you do with your exceptions? Hide them in a log and never look at them? Here is a better idea!


Exception handling and logging is something that is usually done at the end of a development project, if at all. If exceptions or information is logged at all, we almost never look at it until a user tells us that something is not working correctly.

This article suggests a method to log issues and to easily be proactive when it comes to quality.


The tool is called Quilt4Net and it works for all .NET environments. There is one client part that sends data to be logged, using WebAPI to a backend service, where you can watch and analyze. The client is open source and you can download the server and host it yourself.

This setup is particularly good if you have a distributed client, or a server / service without a graphical interface. It also helps greatly for regular websites.

What you get

One of the things the service does is to aggregate exceptions and issues so that you can get a clear overview of what parts and versions of your application have issues.

Another thing it does is to monitor usage of different versions. There is a timeline where you easily can see if clients are updated or not, and when the issues occurred.

In this example you can see that version was used long after that was introduced. The red lines symbolizes exceptions. So, seems to have fewer issues than

Getting started

There are three easy steps that you have to take to get started.

1. Your application

Get the nuget package Quilt4Net from

This can be done from within visual studio.

2. Your code

On application startup. Place the following two lines of code.

Tharga.Quilt4Net.Configuration.ClientToken = "YOUR_TOKEN_HERE";

If this is a service or webservice you will have to provide the startup assembly as a parameter to the BeginRegister method. Otherwise Quilt4Net cannot get hold on what is the initiating assembly.

3. Your ClientToken

Since this component uses a service to register data, it needs to be uniquely identified by the server. Go to and register an account. Under the section Initiatives you will find your ClientToken.

Place that token in the code where it sais YOUR_TOKEN_HERE.

Now you are all done, just run the application and look on the site, the usage should be visible there.

The interesting part

Once the setup is complete we will get to the interesting part. Starting to log exceptions. Whenever an exception is catched it can be logged like this.

catch (Exception exception)

It is always good practice to have your custom exceptions contain error messages that are not variable. You know, like the ones you hate, "Object reference not set to an instance of an object.", and you always ask, what object. You should store variable information in the data part of the exception.

This is really the trick to get the exceptions aggregated correctly. So disregarding if you use Quilt4Net or not, this is how you should write your custom exceptions. But dont forget to put your variables in the data-part of the exception, and do not forget to log the data-part, or show it to the user where appropriate.


If you usually log issues to a flat file, to the event log or not at all, this is worth trying. The best way to get a full understand of any developer tool is to try it out. This one is totally free.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Daniel Bohlin
Sweden Sweden
I have been a developer for over 15 years, mainly with C++ and C#.

You may also be interested in...


Comments and Discussions

GeneralReally good after the update. Pin
Poxet22-May-14 8:34
memberPoxet22-May-14 8:34 
GeneralMy vote of 1 Pin
LuigiCarrione20-May-14 20:02
memberLuigiCarrione20-May-14 20:02 
GeneralMy vote of 1 Pin
GordoFabulous20-May-14 9:22
memberGordoFabulous20-May-14 9:22 
GeneralMy vote of 1 Pin
André Pereira20-May-14 6:24
memberAndré Pereira20-May-14 6:24 
GeneralMy vote of 2 Pin
Philip Liebscher19-May-14 10:02
memberPhilip Liebscher19-May-14 10:02 
GeneralRe: My vote of 2 Pin
Daniel Bohlin19-May-14 10:45
memberDaniel Bohlin19-May-14 10:45 
QuestionThoughts Pin
Dewey19-May-14 8:05
memberDewey19-May-14 8:05 
AnswerRe: Thoughts Pin
Daniel Bohlin19-May-14 10:24
memberDaniel Bohlin19-May-14 10:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.180111.1 | Last Updated 21 May 2014
Article Copyright 2014 by Daniel Bohlin
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid