473,406 Members | 2,293 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,406 software developers and data experts.

caught non-std exception

On FC4 with g++ using STL and Posix threads
and sockets I am catching an exception that
is not a std::exception. Any idea what it
might be? An outline of my catch macro is
below.

Thanks,
Mike.

#define MY_MACRO \
catch (MyExceptions& e) \
{ \
... \\ process them \
} \
catch (std::exception& e) \
{ \
... \\ process them \
} \
catch (...) \
{ \
... \\ what is this \
}

Mar 18 '06 #1
11 2243
Mike wrote:
On FC4 with g++ using STL and Posix threads
and sockets I am catching an exception that
is not a std::exception. Any idea what it
might be? An outline of my catch macro is
below.

Thanks,
Mike.

#define MY_MACRO \
catch (MyExceptions& e) \
{ \
... \\ process them \
} \
catch (std::exception& e) \
{ \
... \\ process them \
} \
catch (...) \
{ \
... \\ what is this \
}


I have no idea, but some systems give you C++-style
exceptions in the event of a signal, like a segmentation
violation of division by zero.

I assume you have ruled out all custom exceptions
that have decided not to derive from std::exception?

Try running the program in gdb, when it stops do
a backtrace with the "bt" command and see which
function is immediately before (in time), that is
below (in the printout), something that resembles
a "throw".

HTH,
- J.
Mar 18 '06 #2
On Sat, 18 Mar 2006 21:27:58 +0100, Jacek Dziedzic wrote:
Mike wrote:
On FC4 with g++ using STL and Posix threads
and sockets I am catching an exception that
is not a std::exception. Any idea what it
might be? An outline of my catch macro is
below.
[...] I assume you have ruled out all custom exceptions
that have decided not to derive from std::exception?

Try running the program in gdb, when it stops do
a backtrace with the "bt" command and see which
function is immediately before (in time), that is
below (in the printout), something that resembles
a "throw".

HTH,
- J.


Sorry to trouble you with a typo. I had:
throw(MyStuff);
instead of:
throw MyException(MyStuff);

I am surprised that it compiled.

Mike.

Mar 18 '06 #3
Mike - EMAIL IGNORED <m_*************@yahoo.com> wrote:
Sorry to trouble you with a typo. I had:
throw(MyStuff);
instead of:
throw MyException(MyStuff);

I am surprised that it compiled.


Why? You can throw pretty much everything. Actually, I cannot think
of anything you cannot throw.

regards
--
jb

(reply address in rot13, unscramble first)
Mar 18 '06 #4
Jakob Bieling wrote:
Mike - EMAIL IGNORED <m_*************@yahoo.com> wrote:
Sorry to trouble you with a typo. I had:
throw(MyStuff);
instead of:
throw MyException(MyStuff);

I am surprised that it compiled.


Why? You can throw pretty much everything.


Well, you can only throw objects, not types, and MyStuff is a type.
Instantiating it would require parens after it.
Mar 18 '06 #5
Rolf Magnus <ra******@t-online.de> wrote:
Jakob Bieling wrote:
Mike - EMAIL IGNORED <m_*************@yahoo.com> wrote:
Sorry to trouble you with a typo. I had:
throw(MyStuff);
instead of:
throw MyException(MyStuff);

I am surprised that it compiled.
Why? You can throw pretty much everything.

Well, you can only throw objects, not types, and MyStuff is a type.
Instantiating it would require parens after it.


Hmm, if MyStuff is a type .. and MyException is also a type .. what
does MyException(MyStuff); mean? I apologize if the answer is really
simple, been a long day ;)

regards
--
jb

(reply address in rot13, unscramble first)
Mar 18 '06 #6
On Sat, 18 Mar 2006 23:43:29 +0100, Jakob Bieling wrote:
Rolf Magnus <ra******@t-online.de> wrote:
Jakob Bieling wrote:

Mike - EMAIL IGNORED <m_*************@yahoo.com> wrote: Sorry to trouble you with a typo. I had:
throw(MyStuff);
instead of:
throw MyException(MyStuff);

I am surprised that it compiled. Why? You can throw pretty much everything.

Well, you can only throw objects, not types, and MyStuff is a type.
Instantiating it would require parens after it.


Hmm, if MyStuff is a type .. and MyException is also a type .. what
does MyException(MyStuff); mean? I apologize if the answer is really
simple, been a long day ;)

regards


In this case, (MyStuff) is of the form:

(const char* file, int line, const char* class,
const char* method, const char* cmt)

I am still surprised that it compiled with the error.
I hope for enlightenment.

Mike.


Mar 19 '06 #7
Mike - EMAIL IGNORED <m_*************@yahoo.com> wrote:
On Sat, 18 Mar 2006 23:43:29 +0100, Jakob Bieling wrote:
Rolf Magnus <ra******@t-online.de> wrote:
Jakob Bieling wrote: Mike - EMAIL IGNORED <m_*************@yahoo.com> wrote: Sorry to trouble you with a typo. I had:
> throw(MyStuff);
> instead of:
> throw MyException(MyStuff);
>
> I am surprised that it compiled. Why? You can throw pretty much everything. Well, you can only throw objects, not types, and MyStuff is a type.
Instantiating it would require parens after it.
Hmm, if MyStuff is a type .. and MyException is also a type ..
what does MyException(MyStuff); mean? [..]

(MyStuff) is of the form:

(const char* file, int line, const char* class,
const char* method, const char* cmt)


Hm. Do you mean MyStuff is typedef'd to be a function pointer taking
those arguments? Or a function taking those arguments? Or is MyStuff a
#define for what is inside those parenthesis?

Either way, I still cannot see how 'throw MyException(MyStuff);' can
compile, if 'throw(MyStuff);' cannot and the other around. I was aware
of the fact that you can only throw objects and not types. But suppose:

1) MyStuff is a typedef (and as such a type), then you could
not have passed it to the ctor of MyException but you could
not have thrown MyStuff either.

2) MyStuff is a function, then 'throw(MyStuff);' would throw a
pointer to this function and 'MyException(MyStuff);' would
pass a pointer to this function to the ctor of MyException.

3) MyStuff is a #define as in

#define MyStuff const char* file, \
int line, \
const char* class, \
const char* method, \
const char* cmt

then 'throw(MyStuff);' expands to something that cannot be
compiled, just like 'throw Exception(MyStuff);' expands to
something that cannot be compiled either.

In other words, I am either missing something, or 'throw(MyStuff);'
compiles if and only if 'throw Exception(MyStuff);' compiles.

regards
--
jb

(reply address in rot13, unscramble first)
Mar 19 '06 #8
Jakob Bieling wrote:
Rolf Magnus <ra******@t-online.de> wrote:
Jakob Bieling wrote:

Mike - EMAIL IGNORED <m_*************@yahoo.com> wrote: Sorry to trouble you with a typo. I had:
throw(MyStuff);
instead of:
throw MyException(MyStuff);

I am surprised that it compiled. Why? You can throw pretty much everything.

Well, you can only throw objects, not types, and MyStuff is a type.
Instantiating it would require parens after it.


Hmm, if MyStuff is a type .. and MyException is also a type .. what
does MyException(MyStuff); mean? I apologize if the answer is really
simple, been a long day ;)


Hmm, right. I was assuming MyStuff is a type, but actually, it could also be
a varible. Only then MyException(MyStuff) would make sense. Then it would
instantiate the type MyException and give MyStuff as argument to the
constructor.

Mar 19 '06 #9
On Sun, 19 Mar 2006 09:50:24 +0100, Jakob Bieling wrote:
[...]
Hm. Do you mean MyStuff is typedef'd to be a function pointer taking
those arguments? Or a function taking those arguments? Or is MyStuff a
#define for what is inside those parenthesis?

Either way, I still cannot see how 'throw MyException(MyStuff);' can
compile, if 'throw(MyStuff);' cannot and the other around. I was aware
of the fact that you can only throw objects and not types. But suppose:

1) MyStuff is a typedef (and as such a type), then you could
not have passed it to the ctor of MyException but you could
not have thrown MyStuff either.

2) MyStuff is a function, then 'throw(MyStuff);' would throw a
pointer to this function and 'MyException(MyStuff);' would
pass a pointer to this function to the ctor of MyException.

3) MyStuff is a #define as in

#define MyStuff const char* file, \
int line, \
const char* class, \
const char* method, \
const char* cmt

then 'throw(MyStuff);' expands to something that cannot be
compiled, just like 'throw Exception(MyStuff);' expands to
something that cannot be compiled either.

In other words, I am either missing something, or 'throw(MyStuff);'
compiles if and only if 'throw Exception(MyStuff);' compiles.

regards


This is how it is, each item in its proper place:
ErrBase::ErrTypBadArg is an enum value
std::exception specifies the base class for BadArg
typedef ErrTmpl<ErrBase::ErrTypBadArg,std::exception> BadArg;
#define ERRLOC __FILE__,__LINE__
#define ERRHERE ERRLOC,className_,methodName
static const char* const className;
const char* const methodName = "myMethod";
const char* const cmt = "dumb error";

throw BadArg(ERRHERE,cmt);

This is a sequence with a long history of success on numerous
systems. The typo was:
throw (ERRHERE,cmt);
which was caught with:
catch (...)

The mystery continues to be that the typo:
throw(ERRHERE,cmt);
compiled. Both the success and failure modes conform to
example 3 above, and in both cases the result is not as
predicted in example 3, with:
FC4, g++ (GCC) 4.0.2 20051125 (Red Hat 4.0.2-8)
..

Mike.

Mar 19 '06 #10
Mike - EMAIL IGNORED <m_*************@yahoo.com> wrote:
On Sun, 19 Mar 2006 09:50:24 +0100, Jakob Bieling wrote:
[...]
Hm. Do you mean MyStuff is typedef'd to be a function pointer
taking those arguments? Or a function taking those arguments? Or is
MyStuff a #define for what is inside those parenthesis?

Either way, I still cannot see how 'throw MyException(MyStuff);'
can compile, if 'throw(MyStuff);' cannot and the other around. I was
aware of the fact that you can only throw objects and not types. But
suppose:

1) MyStuff is a typedef (and as such a type), then you could
not have passed it to the ctor of MyException but you could
not have thrown MyStuff either.

2) MyStuff is a function, then 'throw(MyStuff);' would throw a
pointer to this function and 'MyException(MyStuff);' would
pass a pointer to this function to the ctor of MyException.

3) MyStuff is a #define as in

#define MyStuff const char* file, \
int line, \
const char* class, \
const char* method, \
const char* cmt

then 'throw(MyStuff);' expands to something that cannot be
compiled, just like 'throw Exception(MyStuff);' expands to
something that cannot be compiled either.

In other words, I am either missing something, or
'throw(MyStuff);' compiles if and only if 'throw
Exception(MyStuff);' compiles.

regards


This is how it is, each item in its proper place:
ErrBase::ErrTypBadArg is an enum value
std::exception specifies the base class for BadArg
typedef ErrTmpl<ErrBase::ErrTypBadArg,std::exception> BadArg;
#define ERRLOC __FILE__,__LINE__
#define ERRHERE ERRLOC,className_,methodName
static const char* const className;
const char* const methodName = "myMethod";
const char* const cmt = "dumb error";

throw BadArg(ERRHERE,cmt);

This is a sequence with a long history of success on numerous
systems. The typo was:
throw (ERRHERE,cmt);


This utilizes the global "operator," (comma operator). It evaluates
all arguments and returns the last one (the right-most one). So if you
had a "catch(char* c)" clause, it should have reached that.

hth
--
jb

(reply address in rot13, unscramble first)
Mar 19 '06 #11
Jakob Bieling <ar****************@rot13.com> wrote:
const char* const cmt = "dumb error"; throw (ERRHERE,cmt);
had a "catch(char* c)" clause, it should have reached that.


Sorry, I meant a "catch (char const* c)" clause .. did not see the
first 'const' :)

regards
--
jb

(reply address in rot13, unscramble first)
Mar 19 '06 #12

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

Similar topics

1
by: Sean | last post by:
Hi, I found if a wx.TextCtrl is used in a subclass of wx.Dialog, the event wx.EVT_TEXT_ENTER can not be caught, that is, key code of RETURN can not be indentified. class MyDialog(wx.Dialog):...
2
by: Brian | last post by:
We have an ASP program we are testing. So far only 1 machine gets this error. Any suggestions where to look, in order to debug this error? Thanks in advance for your help! ASP caught this...
1
by: nzanella | last post by:
Hello, I have two .cpp files. The first one contains: Foo *foo; and in the second one contains: Foo foo;
3
by: vidalsasoon | last post by:
here is my inheritance class hierchy... System.Windows.Forms.Form | Global | Form1-------Form2
5
by: Mark Kamoski | last post by:
Hi Everyone-- How can one get the line number of where an error was thrown and/or caught? For example, note the following, for use at any given point in a piece of code: ....to get the...
0
by: micky | last post by:
how can i solve this error?? System.UnauthorizedAccessException was caught Message="Access to the path 'c:\\inetpub\\wwwroot\\Soliy\\Config\\Options.config' is denied." Source="mscorlib"...
0
by: vj | last post by:
I'm trying to create a semi restricted env where users are not able to bring my application down. I know the following: 100000000**10000000 will not be caught by signal.alarm since it is...
3
by: thomson | last post by:
Hi All, Are there any sort of exceptions that cannot be caught by the Runtime, Any Insights? Thanks in Advance thomson
0
by: masterjuan | last post by:
Networks Hacking (hack C:/ drives, severs...)and security holes all on my website & hacking commands and I explain ways of erasing your tracks so you dont get caught doing "bad" things... What do...
6
by: ruka_at_ | last post by:
Hi, why is KeyboardInterrupt not caught (xp)? import sys try: inp = sys.stdin.read() except (KeyboardInterrupt, SystemExit): print "kbd-interr,SystemExit" except EOFError: print "eof...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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...
0
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...
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.