473,320 Members | 1,982 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,320 software developers and data experts.

Own exception class - plus in typename???

Hello everybody,

I've created for one of my classes a exception class derivated from
System.Exception. This exception class is public and lies within my
class as inner class.

When I throw this exception I can't catch it with its name! When I try
to catch it with it's name then the catch-block will be ignored.... So
I've made a general catch with System.Exception and printed the
runtime type...

....
catch (Exception ex)
{
Console.WriteLine(ex.getType());
}
....

To my surprise the I've got the following typename:
namespace.outer_classname+ownexception_classname

What is this plus in the typename? I've never seen this bevore... Am I
doing something wrong? Or is there a trick to catch exceptions of this
type?

Help would be appreciated

Michael Wisheu
Dec 29 '07 #1
4 1488
mi*****@wisheu.eu wrote:
I've created for one of my classes a exception class derivated from
System.Exception. This exception class is public and lies within my
class as inner class.

When I throw this exception I can't catch it with its name! When I try
to catch it with it's name then the catch-block will be ignored.... So
I've made a general catch with System.Exception and printed the
runtime type...

...
catch (Exception ex)
{
Console.WriteLine(ex.getType());
}
...

To my surprise the I've got the following typename:
namespace.outer_classname+ownexception_classname

What is this plus in the typename? I've never seen this bevore... Am I
doing something wrong? Or is there a trick to catch exceptions of this
type?
catch(outer_classname.ownexception_classname ex)

or

catch(namespace.outer_classname.ownexception_class name ex)

is probably what you are looking for.

Arne

Dec 29 '07 #2
mi*****@wisheu.eu wrote:
I've created for one of my classes a exception class derivated from
System.Exception. This exception class is public and lies within my
class as inner class.

When I throw this exception I can't catch it with its name! When I try
to catch it with it's name then the catch-block will be ignored.... So
I've made a general catch with System.Exception and printed the
runtime type...

...
catch (Exception ex)
{
Console.WriteLine(ex.getType());
}
...

To my surprise the I've got the following typename:
namespace.outer_classname+ownexception_classname

What is this plus in the typename? I've never seen this bevore... Am I
doing something wrong? Or is there a trick to catch exceptions of this
type?
And regarding the plus: see
http://msdn2.microsoft.com/en-us/library/w3f99sx1.aspx
(go down to th etable with "Delimiter Meaning").

Arne
Dec 29 '07 #3
<mi*****@wisheu.euwrote:
I've created for one of my classes a exception class derivated from
System.Exception. This exception class is public and lies within my
class as inner class.

When I throw this exception I can't catch it with its name! When I try
to catch it with it's name then the catch-block will be ignored..
No, it won't - not if you use the correct type name. Is your type name
one which is also available not as a nested class? If so, it's probably
trying to catch that instead.

The "+" is just what the CLR uses to identify nested clases.

If that doesn't help, could you post a short but complete program which
demonstrates the problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
Dec 29 '07 #4
Thanks folks for your support!

I've NOW know that the plus stands for an inner class. But this wasn't
the problem... When you have several inner exception classes and you
program after 9pm then you should really look twice if you're really
catching the right exception...

Ín my case I wanted to catch the right exception but I haven't
administratrive privileges (Vista and it's lovely UAC) and another
inner exception was raised before. And this one wasn't catched!

It seems that is time to go to bed now... Thanks for all your help and
sorry for this silly help request.

Best regards

Michael
Dec 29 '07 #5

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

Similar topics

12
by: Ritz, Bruno | last post by:
hi in java i found that when a method has a throws clause in the definition, callers must either handle the exceptions thrown by the method they are calling or "forward" the exception to the...
4
by: Steve | last post by:
I'll be the first to admit, I'm not entirely clear on the appropriate usage of either. From what I am reading in my books, a Struct and a Class are pretty much the same, with the difference being,...
7
by: Mikhail N. Kupchik | last post by:
Hi All. I have a question regarding Herb Sutter's idiom of implementation of operator= via nonthrowing swap() member function, to guarantee strict exception safety. The idea of the idiom is...
13
by: Mike Austin | last post by:
Hi all. Just working on a small virtual machine, and thought about using vector iterators instead of pointer arithmetic. Question is, why does an iterator plus any number out of range not...
4
by: Rob Richardson | last post by:
Greetings! I am working on an application that targets a Pocket PC running Windows CE and SQL Server CE. Almost all functions in the application use a Try block with a Catch block that looks...
3
by: Nindi73 | last post by:
Hi, I am in need of a deep copy smart pointer (Boost doesn't provide one) which doesnt require the contained types to have a virtual copy constructor. I wrote a smart pointer class that I think...
2
by: Dom Jackson | last post by:
Hello - I have a problem where I need to test some numeric code using a variety of built-in integer types: obj_type1 = obj_type2 OP obj_type3; // is obj_type1 correct? If I test with 10...
1
by: alan | last post by:
I have a set of classes, cell, cell_body, and cell_internal. cell_internal is an abstract base class, intended to encapsulate deferred computation. cell is just a wrapped pointer around...
6
by: Gaijinco | last post by:
I'm trying to do a template class Node. My node.hpp is: #ifndef _NODE_HPP_ #define _NODE_HPP_ namespace com { namespace mnya { namespace carlos { template <typename T>
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.