473,654 Members | 3,042 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Throwing Nice Exceptions

I have a point in my code where I can get an exception if the network is not
available. This exception is kind of ugly for the user to see. I'd like to
catch and throw new exception that contains only my error string and an OK
button. If I say throw new System.Exceptio n("The network is not available,
the list will not contain data."), the user sees text they don't need to see,
and they have to choose between break and continue buttons.

Any ideas?
--
Randy
May 10 '06 #1
3 938
"randy1200" <ra*******@news groups.nospam> wrote in message
news:CE******** *************** ***********@mic rosoft.com...
I have a point in my code where I can get an exception if the network is
not
available. This exception is kind of ugly for the user to see. I'd like to
catch and throw new exception that contains only my error string and an OK
button. If I say throw new System.Exceptio n("The network is not available,
the list will not contain data."), the user sees text they don't need to
see,
and they have to choose between break and continue buttons.

Any ideas?
--
Randy


Maybe I misunderstand something, but why don't you just catch the exception
and handle it the way you like it.

Marcus
May 11 '06 #2
>I have a point in my code where I can get an exception if the network is
not
available. This exception is kind of ugly for the user to see. I'd like to
catch and throw new exception that contains only my error string and an OK
button. If I say throw new System.Exceptio n("The network is not available,
the list will not contain data."), the user sees text they don't need to
see,
and they have to choose between break and continue buttons.


Exception with an OK button is a very nice idea.
--
Vladimir Nesterovsky
May 11 '06 #3
randy1200 <ra*******@news groups.nospam> wrote in
news:CE******** *************** ***********@mic rosoft.com:
I have a point in my code where I can get an exception if the network
is not available. This exception is kind of ugly for the user to see.
I'd like to catch and throw new exception that contains only my error
string and an OK button. If I say throw new System.Exceptio n("The
network is not available, the list will not contain data."), the user
sees text they don't need to see, and they have to choose between
break and continue buttons.

Any ideas?


That sounds interesting, how is that done?

Is there a C++ only equivalent?
May 15 '06 #4

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

Similar topics

5
4667
by: Mark Oueis | last post by:
I've been struggling with this question for a while. What is better design? To design functions to return error codes when an error occures, or to have them throw exceptions. If you chose the former, i have a few questions that need to be answered. 1) What about functions that need to return a value regardless of the error. How can they also return an error code unless the function has "output" parameters. This seems messy and...
21
4415
by: mihai | last post by:
People say that is a bad technique to throw exception from constructors; and that the solution would be to create a function _create_ to initialize an object. What about copy constructors? How can we avoid throwing exceptions? If we already have an abject witch was initialized wit _create_ we will be forced to call create in copy constructor and to throw exceptions from it. Have a nice day,
40
13511
by: Kevin Yu | last post by:
is it a bad programming design to throw exception in the try block then catch it??
40
36082
by: Sek | last post by:
Is it appropriate to throw exception from a constructor? Thats the only way i could think of to denote the failure of constructor, wherein i am invoking couple of other classes to initialise the object. TIA Sek
6
3553
by: Marvin Barley | last post by:
I have a class that throws exceptions in new initializer, and a static array of objects of this type. When something is wrong in initialization, CGI program crashes miserably. Debugging shows uncaught exception. How to catch an exception that happened before main() try { ... } catch (...) { ... } block? Is there a way?
1
3272
by: usenet | last post by:
I wrote some sample code (see below) for nested exception throwing i.e. my catch blocks are throwing exceptions of their own (for simplicity I used standard exceptions). I am getting some extraneous characters (St9) in my final output. Can anyone kindly help me interpret that please? Thanks, Ramesh
4
1955
by: Jay Dee | last post by:
I have a query about throwing exceptions. To throw an exception I type something like: try { // do somthing } catch (ArgumentOutOfRangeException) {
3
1944
balabaster
by: balabaster | last post by:
Hey all, this might seem somewhat remedial but I'm unable to find any documentation on it - it pertains to throwing exceptions within a DLL. I've written a DLL that contains a bunch of classes. One of my methods validates the contents of a file and throws any necessary exceptions based on invalid content - I'm using a standard "throw new exception..." call ...the thing is, when my code reaches the line where the exception is thrown, my...
21
1707
by: Chris M. Thomasson | last post by:
Is it every appropriate to throw in a dtor? I am thinking about a simple example of a wrapper around a POSIX file... ________________________________________________________________________ class file { FILE* m_handle; public: // ; ~file() /* throw() */ {
0
8375
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...
0
8815
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8707
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8482
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
8593
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
7306
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
6161
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
5622
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
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.