473,396 Members | 2,020 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

what kind of exception to use

I have a class and some of its operations are not valid under certains
cercumstances. what if the user clicks on the button which lauches this
operation?

Should I use InvaldoperationException or should I derive my own Exception
from System.ApplicationException? Iam not sure what to do.

--
cody

[Freeware, Games and Humor]
www.deutronium.de.vu || www.deutronium.tk
Nov 15 '05 #1
3 1037
Hi,

It depends on how you are going to handle these exceptions. If the handling
is simple - say, just display a message box - InvalidOperationException
should be fine. But if different exceptions should be handled in different
ways - I'd suggest deriving your own exception classes.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"codymanix" <do*********************@gmx.de> wrote in message
news:OU**************@TK2MSFTNGP12.phx.gbl...
I have a class and some of its operations are not valid under certains
cercumstances. what if the user clicks on the button which lauches this
operation?

Should I use InvaldoperationException or should I derive my own Exception
from System.ApplicationException? Iam not sure what to do.

--
cody

[Freeware, Games and Humor]
www.deutronium.de.vu || www.deutronium.tk


Nov 15 '05 #2
> It depends on how you are going to handle these exceptions. If the
handling
is simple - say, just display a message box - InvalidOperationException
should be fine. But if different exceptions should be handled in different
ways - I'd suggest deriving your own exception classes.

Yes, in most cases I will simply dispaly a messagebox displaying the message
in the exception. but i don't want to catch *all* exceptions. I don't if it
is good for the user to see an exception saying "nullreferenceexception: the
object wasn't set to a instance".

Zhe user should see messages like: an error occured during the loading of
the customer-data or something like that.

--
cody

[Freeware, Games and Humor]
www.deutronium.de.vu || www.deutronium.tk
Nov 15 '05 #3
Then you should derive your own exception class from ApplicationException
and catch exceptions of this class only to display the error messages.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"cody" <do*********************@gmx.de> wrote in message
news:br************@ID-176797.news.uni-berlin.de...
It depends on how you are going to handle these exceptions. If the handling
is simple - say, just display a message box - InvalidOperationException
should be fine. But if different exceptions should be handled in different ways - I'd suggest deriving your own exception classes.

Yes, in most cases I will simply dispaly a messagebox displaying the

message in the exception. but i don't want to catch *all* exceptions. I don't if it is good for the user to see an exception saying "nullreferenceexception: the object wasn't set to a instance".

Zhe user should see messages like: an error occured during the loading of
the customer-data or something like that.

--
cody

[Freeware, Games and Humor]
www.deutronium.de.vu || www.deutronium.tk


Nov 15 '05 #4

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

Similar topics

3
by: codymanix | last post by:
I have a class and some of its operations are not valid under certains cercumstances. what if the user clicks on the button which lauches this operation? Should I use InvaldoperationException or...
24
by: Steven T. Hatton | last post by:
If I understand correctly, I have no assurance that I can determine the type of a simple class instance thrown as an exception unless I explicitly catch it by name. (non-derived classes having no...
6
by: Muscha | last post by:
Hello, I have the following exception in my app, have been chasing it up for the past few days none to avail. Help does anyone know what this may be? Unhandled Exception:...
11
by: Howard Kaikow | last post by:
I'm using the code below, but an error is not getting trapped. Where can such errors occur? In another process? Try SomeCode Catch ex As Exception Dim strMsg() As String = Split(ex.ToString,...
5
by: Tiglath | last post by:
We are building a high performance system and suddenly the cost of using exception has been magnified. What is the actual cost of having a frequent call inside a try-catch block when the vast...
2
by: geordietx | last post by:
Hi, I needed an answer to this question so I thought I'd find a Java forum that appeared to be friendly and tolerant of those who aren't well-versed in Java. Guess who won?? :-) In the last week,...
10
by: Digital Puer | last post by:
Sorry for the rudimentary question. I found the following posting online and did not know the answer myself. "Reminds me of a time I had a phone interview concerning a C++ job. Didn't help...
28
by: gnuist006 | last post by:
I have some code like this: (if (test) (exit) (do something)) or (if (test)
4
by: Gestorm | last post by:
Hi all, I found a macro "USE_VAR" in the code of bash-3.2 as follows: /*file: bash-3.2/shell.c*/ 344 USE_VAR(argc); 345 USE_VAR(argv); 346 USE_VAR(env); 347 USE_VAR(code); 348 ...
3
by: vamsioracle | last post by:
Hi could someone explain me what kind of a code is this. CREATE OR REPLACE PACKAGE BODY APPS.FFP3613_01011951 AS /* Code generated by Oracle FastFormula - do not edit. Formula Name:...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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,...
0
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...

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.