Solved

Collecting Exceptions

Posted on 2007-03-22
2
256 Views
Last Modified: 2010-04-16
Hello
I was told that there is a way to collect exceptions ( Try/Catch )  as I'm running my application without creating a Namespace level string and adding Exception error messages to it.
I have a lot of various Try/Catch blocks in various Classes/Methods in different parts of my program. I need to be able to collect them all and then output in the Log file.

Any help would be much appreciated.
0
Comment
Question by:compulaw
2 Comments
 
LVL 2

Accepted Solution

by:
_Eyeball_ earned 250 total points
ID: 18774090
i would do it the following way:

public static class ErrorCollector
    {
        private static List<System.Exception> m_ErrorList =
            new List<Exception>();

        public static void WriteError(System.Exception ex)
        {
            m_ErrorList.Add(ex);
        }


        public static void WriteLog(string path)
        {
            // Write Log
            m_ErrorList = new List<Exception>();
        }      
    }

This class could be used from everywhere as long your are in the same assembly!

I hope that's what u mean!

best regards
0
 

Author Comment

by:compulaw
ID: 18776267
That could definately work but I don't want to create extra classes/Methods for this.
I believe I'm talking about throwing exceptions...something like:

try
{}
catch(Exception ex)
{
throw new Exception=.. something
}

so this way I collect exceptions and then i can optupid them in some other part of the program. I'm not 100% sure what I'm talking about here... help :)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now