bezzad / ErrorControlSystem

ErrorControlSystem is a .NET library created to automate handling .NET Windows-Base application exceptions and raise that to a sql server. This exception handler have some features as screen capturing, fetch server date time in exception occurrence time and etc.
http://bezzad.github.io/ErrorControlSystem/
GNU General Public License v3.0
32 stars 14 forks source link

Add custom object to all error objects programmatically #12

Closed bezzad closed 9 years ago

bezzad commented 9 years ago

Some times we need to have difference between one application on two computers by duplicate user info, so no different between both of them and we need to add some property to all Errors for sign that app exceptions in database. In ExpHandlerEngine.Start must be have a parameters to give the custom object.

bezzad commented 9 years ago

A dictionary of key/value data added to ExceptionHandler class, so that will be stored in exceptions as additional data.


public static Dictionary<string, string> AttachExtraData = new Dictionary<string, string>();

So when any exceptions raised then the additional data also added to exception object.


// Attach extra data to error object
foreach (var item in AttachExtraData)
   exp.Data.Add(item.Key, item.Value);

Now, you can to add extra data to any happened exceptions from app. For example:


// Add extra data for labeling exceptions
ExceptionHandler.AttachExtraData.Add("TestKey", "beta version");