Solved

Collecting Exceptions

Posted on 2007-03-22
2
292 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

739 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