PC Review


Reply
Thread Tools Rate Thread

Can I have my own default Exception class

 
 
Parag
Guest
Posts: n/a
 
      5th Dec 2003
Hi,

I am writing error handling mechanism for a large website and one of
the requirements that has come is whether it is possible to have the
..NET application whenever it throws exception it throws a custom
defined exception. For e.g.
Default behaviour is as shown:
Try
some code
Catch Ex as Exception

End try

Can I have something like for all types of exceptions

Try
some code
Catch Ex as MyException

End try

This should be the default behaviour of my .NET application

Regards

Parag
 
Reply With Quote
 
 
 
 
Mike Bulava
Guest
Posts: n/a
 
      5th Dec 2003
Yes, you can do what you asked, you can actually have multipul catch
statements within the try to catch different types of exceptions to.

Mike Bulava

"Parag" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> I am writing error handling mechanism for a large website and one of
> the requirements that has come is whether it is possible to have the
> .NET application whenever it throws exception it throws a custom
> defined exception. For e.g.
> Default behaviour is as shown:
> Try
> some code
> Catch Ex as Exception
>
> End try
>
> Can I have something like for all types of exceptions
>
> Try
> some code
> Catch Ex as MyException
>
> End try
>
> This should be the default behaviour of my .NET application
>
> Regards
>
> Parag



 
Reply With Quote
 
Jay B. Harlow [MVP - Outlook]
Guest
Posts: n/a
 
      5th Dec 2003
Parag,
In addition to Mike's comments.

To define your own exceptions simply inherit from
System.ApplicationException or System.SystemException.

You can inherit from System.Exception itself, however that is not
recommended.

You may want to consider defining MyBaseException that all your user
exceptions inherit from.

For the .NET guidelines on creating exceptions see:
http://msdn.microsoft.com/library/de...Guidelines.asp

Hope this helps
Jay

"Parag" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> I am writing error handling mechanism for a large website and one of
> the requirements that has come is whether it is possible to have the
> .NET application whenever it throws exception it throws a custom
> defined exception. For e.g.
> Default behaviour is as shown:
> Try
> some code
> Catch Ex as Exception
>
> End try
>
> Can I have something like for all types of exceptions
>
> Try
> some code
> Catch Ex as MyException
>
> End try
>
> This should be the default behaviour of my .NET application
>
> Regards
>
> Parag



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
creating my own exception class Tony Johansson Microsoft C# .NET 1 29th Sep 2008 06:54 PM
Get derived class from base class (find actual exception from Exception)? Zytan Microsoft C# .NET 4 30th Mar 2007 07:06 PM
How to export a class that inherits from unmanaged exception class Bob Altman Microsoft VC .NET 3 17th Oct 2006 08:49 PM
default exception handler for a class with visibility to its metho =?Utf-8?B?LSB2aGFubmFr?= Microsoft C# .NET 0 30th Jun 2005 05:52 AM
Throwwing exception from __gc class to c# class Steven Cool Microsoft VC .NET 2 16th Apr 2004 08:15 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:34 PM.