473,804 Members | 2,202 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Viewing Exception Details

Hi,

Is it a code practice for me to have writen the following Class? -

using System;
using System.Collecti ons.Generic;
using System.Text;
using System.Windows. Forms;
using System.Collecti ons;

namespace mine
{
static class ExceptionDetail s
{
static public string Details(Excepti on exception)
{
string exceptionString = "";

try
{
int i = 0;
while (exception != null)
{
exceptionString += "*** Exception Level " + i + "
***\n";
exceptionString += "Message: " + exception.Messa ge
+ "\n";
exceptionString += "Source: " + exception.Sourc e +
"\n";
exceptionString += "Target Site: " +
exception.Targe tSite + "\n";
exceptionString += "Stack Trace: " +
exception.Stack Trace + "\n";
exceptionString += "Data: ";
foreach (DictionaryEntr y keyValuePair in
exception.Data)
exceptionString += keyValuePair.Ke y.ToString()
+ ":" + keyValuePair.Va lue.ToString();
exceptionString += "\n***\n\n" ;

exception = exception.Inner Exception;

i++;
}
}
catch{}

return exceptionString ;
}
}
}

I then use it as follows -

try
{
...
}
catch (Exception exception)
{
MessageBox.Show (ExceptionDetai ls.Details(exce ption), "Error.");
}

Thanks,

Barry.
Nov 19 '08 #1
1 9389
Well, if you want to show the details, and this is what you want to see,
then by all means, use it. I'd probably move the call to MessageBox.Show
into the method as well (save some typing) and call it something else (like
DisplayDetails) .

However, if you want to use this for other purposes (like logging to a
file) then it is just fine the way it is (although there are other logging
mechanisms out there).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

<Ma************ *@gmail.comwrot e in message
news:08******** *************** ***********@35g 2000pry.googleg roups.com...
Hi,

Is it a code practice for me to have writen the following Class? -

using System;
using System.Collecti ons.Generic;
using System.Text;
using System.Windows. Forms;
using System.Collecti ons;

namespace mine
{
static class ExceptionDetail s
{
static public string Details(Excepti on exception)
{
string exceptionString = "";

try
{
int i = 0;
while (exception != null)
{
exceptionString += "*** Exception Level " + i + "
***\n";
exceptionString += "Message: " + exception.Messa ge
+ "\n";
exceptionString += "Source: " + exception.Sourc e +
"\n";
exceptionString += "Target Site: " +
exception.Targe tSite + "\n";
exceptionString += "Stack Trace: " +
exception.Stack Trace + "\n";
exceptionString += "Data: ";
foreach (DictionaryEntr y keyValuePair in
exception.Data)
exceptionString += keyValuePair.Ke y.ToString()
+ ":" + keyValuePair.Va lue.ToString();
exceptionString += "\n***\n\n" ;

exception = exception.Inner Exception;

i++;
}
}
catch{}

return exceptionString ;
}
}
}

I then use it as follows -

try
{
...
}
catch (Exception exception)
{
MessageBox.Show (ExceptionDetai ls.Details(exce ption), "Error.");
}

Thanks,

Barry.
Nov 19 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1605
by: Mita | last post by:
I Am trying to post my form on to a second page, but it keeps coming with a, error: Exception Details: System.Web.HttpException: The View State is invalid for this page and might be corrupted. Any ideas? Please help.
2
6027
by: Bill Nguyen | last post by:
I got this error emssage trying to run an ASP.NET application on my Win2003/IIS6.0 server: Exception Details: System.UnauthorizedAccessException: Access to the path "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\gsic_license\af8d1ef2\60bfeb0b" is denied. Your help is greatly appreciated. Bill
6
6128
by: Tony | last post by:
Dear All, When I run an example program on the http://www.dotnetjunkies.com/quickstart/util/srcview.aspx?path=/quickstart/aspplus/samples/webforms/data/datagrid1.src&file=VB\datagrid1.aspx&font=3 I received an error message: "The ConnectionString property has not been initialized.
0
2784
by: silesius | last post by:
I've been using VS.NET 2003 to develop a webapplication using C#. Today I exported the application to another webserver I begun experiencing problems. It's a simple application that retrieves some information from an Access database. It worked fine when I ran on my home computer. I use a datagrid witha a dataset and a parameterized query to retrieve some customer specific information. Customer logs in, I store the username they log in...
0
1796
by: masago | last post by:
Hi....how are you ?? they can help me to solve this problem ?? Access to the path = "c:\windows\microsoft.net\framework\v1.1.4322\Temporary ASP.NET = Files\reports\06639073\bbab30a7" is denied.=20 Description: An unhandled exception occurred during the execution of the =
1
4770
by: differentsri | last post by:
THIS IS AN ASP.NET 1.1 APPLICATION IAM TRYING TO UPDATE THE FIELD BUT I AM NOT ABLE TO UPDATE IT? CAN U TELL THE REASON ? IT IS GIVING THE FOLLOWING ERROR BELOW I HAVE ALSO GIVEN THE CODE OF THE PROGRAM PLEASE HELP ME Server Error in '/WebApplication1' Application. -------------------------------------------------------------------------------- Input string was not in a correct format. Description: An unhandled exception occurred...
2
1164
by: itsvineeth209 | last post by:
Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. Source Error: Line 236: GridViewRow row = GridView1.Rows; Line 237:
4
2186
by: minhtran | last post by:
Hi All I create web page as ASP.NET . The program runs on localhost no problem,but when we upload on server has an error as : An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Exception: File not found Source Error: Line 244: Dim j As Integer Line 245: Dim k As Integer
3
4453
by: Lee Cripps | last post by:
Hi, Not sure if my question belongs in an ASP.NET or MSSQL forum.. I have an ASP.NET webpage built in VS2010 with an Input field with the functionality to browse to a network directory, select a text file, read content and upload the data to an MSSQL database table. Nothing fancy. I am programming on a client, debugging, and running the website locally and the process works like a charm. When I publish the site to a webserver, browse to...
0
9715
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10354
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10097
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9175
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7642
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6867
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5535
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4313
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3002
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.