Throw new Excption ("bla, bla, bla")
....
Catch E as Exception
If E.Message.Equal s("bla, bla, bla") Then ...
Mostly i just use the standard "Exception"-object whenever i throw an
exception, but it would be nice sometimes to make you own
"MyExceptio n"-object that you
can then easier Catch. using:
Catch Exp as MyException
....
Whenever i use the standard exception-object i check to see if the E.Message
equals the one i made, but since this isn't a very good way of coding, so
how do i make my own Exception-object. Do i need to make a new class that
inherits/implements from the Exception.class , or is there a way to do it
without starting making a exception-class for each object you want a
specialized exception for. Someting you do when you trow the exception for
example? 3 3193
"Jarod_24" <ja******@hotma il.com> schrieb Throw new Excption ("bla, bla, bla") ... Catch E as Exception If E.Message.Equal s("bla, bla, bla") Then ...
Mostly i just use the standard "Exception"-object whenever i throw an exception, but it would be nice sometimes to make you own "MyExceptio n"-object that you can then easier Catch. using:
Catch Exp as MyException ...
Whenever i use the standard exception-object i check to see if the E.Message equals the one i made, but since this isn't a very good way of coding, so how do i make my own Exception-object. Do i need to make a new class that inherits/implements from the Exception.class , or is there a way to do it without starting making a exception-class for each object you want a specialized exception for. Someting you do when you trow the exception for example?
Has been discussed here in the past days. See subject "Error handling -
custom 'throw?'"
--
Armin http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
* "Jarod_24" <ja******@hotma il.com> scripsit: Throw new Excption ("bla, bla, bla") ... Catch E as Exception If E.Message.Equal s("bla, bla, bla") Then ...
Mostly i just use the standard "Exception"-object whenever i throw an exception, but it would be nice sometimes to make you own "MyExceptio n"-object that you can then easier Catch. using:
Catch Exp as MyException ...
Whenever i use the standard exception-object i check to see if the E.Message equals the one i made, but since this isn't a very good way of coding, so how do i make my own Exception-object. Do i need to make a new class that inherits/implements from the Exception.class , or is there a way to do it without starting making a exception-class for each object you want a specialized exception for. Someting you do when you trow the exception for example?
This depends on various aspects:
* If there is already an appropriate exception class defined in the
.NET Framework, I would use this class instead of creating a new
class.
* If there is no class available in the .NET Framework, I would create
a custom exception class in order to make it easier to handle the
exceptions of a certain type.
Notice that it doesn't make sense to create a new exception class for
each exception -- sometimes it's better to use the same exception class,
for example, 'IOException'.
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Jarod,
In addition to the other comments.
These are the guidelines that I try to follow: http://msdn.microsoft.com/library/de...Guidelines.asp
The following article provides a good template for defining well-tempered
exceptions: http://msdn.microsoft.com/library/de...rp08162001.asp
Although the code is in C# it should be easily converted to VB.NET. Catch E as Exception If E.Message.Equal s("bla, bla, bla") Then ...
Did you know you can use a When clause here?
Try
Catch ex As Exception When ex.Message.Equa ls("bla, bla, bla")
Catch ex As Exception When ex.Message.Equa ls("alb, alb, alb")
End Try
Hope this helps
Jay
"Jarod_24" <ja******@hotma il.com> wrote in message
news:5d******** *************** *******@news.te ranews.com... Throw new Excption ("bla, bla, bla") ... Catch E as Exception If E.Message.Equal s("bla, bla, bla") Then ...
Mostly i just use the standard "Exception"-object whenever i throw an exception, but it would be nice sometimes to make you own "MyExceptio n"-object that you can then easier Catch. using:
Catch Exp as MyException ...
Whenever i use the standard exception-object i check to see if the
E.Message equals the one i made, but since this isn't a very good way of coding, so how do i make my own Exception-object. Do i need to make a new class that inherits/implements from the Exception.class , or is there a way to do it without starting making a exception-class for each object you want a specialized exception for. Someting you do when you trow the exception for example? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Mark |
last post by:
I'm betting it me. Here is the simple schema I'm using:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
jaxb:version="1.0">
<xs:annotation>
<xs:appinfo>
|
by: Nick Keighley |
last post by:
Hi,
In the beginning the code was:-
BRUSHH new_brush = create_brush()
BRUSHH old_brush = select_brush (new_brush)
draw(...)
select_brush (old_brush)
destroy_brush (new_brush)
|
by: Jarod_24 |
last post by:
Throw new Excption ("bla, bla, bla")
....
Catch E as Exception
If E.Message.Equals("bla, bla, bla") Then ...
Mostly i just use the standard "Exception"-object whenever i throw an
exception, but it would be nice sometimes to make you own
"MyException"-object that you can then easier Catch. using:
|
by: Chris Langston |
last post by:
We are seeing a very frustrating intermittent problem. We are making
Synchronious web service method calls from a .NET windows Service using the
following syntax
WebRequest.getResponse call it occasionally fails with the following error:
1) Exception Information
*********************************************
Exception Type: System.Net.WebException
Status: ConnectFailure
|
by: yogpjosh |
last post by:
Hello All,
I was asked a question in an interview..
Its related to dynamically allocated and deallocated memory.
eg.
//start
char * p = new char;
...
| |
by: dbahooker |
last post by:
team
i'm having a tough time getting these data readers to work correctly
I'd just like to be able to centralize my GetDataReader functions; so i
can pass a simple SQL statement and be passed back a valid DataReader
object.
I've been slaving with this all day long. I've been trying 'new' and
not new and just slaving over this; im calling it an early day..
|
by: Ben Voigt |
last post by:
Under certain circumstances I get:
First-chance exception at 0x7c812a5b (kernel32.dll) in LTMGUI.exe:
0xC0020001: The string binding is invalid.
First-chance exception at 0x7c812a5b (kernel32.dll) in LTMGUI.exe: Microsoft
C++ exception: at memory location 0x00000000..
Unhandled exception at 0x7c812a5b (kernel32.dll) in LTMGUI.exe: 0xC0020001:
The string binding is invalid.
Googling this exception brought me to a blog posting by Chris...
|
by: Premal |
last post by:
Hi,
I tried to make delete operator private for my class. Strangely it is
giving me error if I compile that code in VC++.NET. But it compiles
successfully on VC++6.o. Can anybody give me inputs about it. I wanted
that on my class delete should not work. Object pointer should be
deleted using my function only which is taking care of reference count
for particular class.
Thanx in advance for your inputs.
|
by: Rafe |
last post by:
Hi,
I'm working within an application (making a lot of wrappers), but the
application is not case sensitive. For example, Typing obj.name,
obj.Name, or even object.naMe is all fine (as far as the app is
concerned). The problem is, If someone makes a typo, they may get an
unexpected error due accidentally calling the original attribute
instead of the wrapped version. Does anyone have a simple solution for
this?
|
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...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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...
|
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,...
|
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...
|
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...
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |