Hello everyone,


This question is about when it is allowed to call throw to re-throw
exception -- make the exception re-throw.

I can only think of two situations,

1. in catch block of an exception;
2. in unexpected handler.

For (2), in unexpected handler, since the input parameter is null, so in
order to get the exception information, we need to re-throw it and catch it
to get exception informaiton.

Is my understanding correct? Here is some pseudo code from Bjarne's book.

[Code]
// suppose throwY is unexpcted handler
void throwY() throw (Yunexpected)
{
try{
throw; // have to re-throw and catch in order to get exception
information since current input parameter is null and has no exception
information, my understanding correct?
} catch (Network_exception& p)
{
throw (Yunexpected (&p));
} catch (...)
{
throw (Yunexpected (0));
}
}
[/Code]


thanks in advance,
George

Re: unexpected exception handler by Igor

Igor
Tue Jan 08 07:49:59 CST 2008

"George" <George@discussions.microsoft.com> wrote in message
news:7B351A53-4DBC-43ED-874C-C073E038B899@microsoft.com
> This question is about when it is allowed to call throw to re-throw
> exception -- make the exception re-throw.
>
> I can only think of two situations,
>
> 1. in catch block of an exception;
> 2. in unexpected handler.

Any function can contain a "throw;" statement. Such a function can be
called from a catch clause (or from unexpected() handler), directly or
indirectly:

void rethrow() { throw; }

try {...}
catch (const exception&) { rethrow(); }

If "throw;" statement is encountered while no exception is caught, the
program calls terminate().

> For (2), in unexpected handler, since the input parameter is null, so
> in order to get the exception information, we need to re-throw it and
> catch it to get exception informaiton.
>
> Is my understanding correct?

Sounds about right.

> Here is some pseudo code from Bjarne's
> book.
>
> [Code]
> // suppose throwY is unexpcted handler
> void throwY() throw (Yunexpected)
> {
> try{
> throw; // have to re-throw and catch in order to get exception
> information since current input parameter is null and has no exception
> information, my understanding correct?
> } catch (Network_exception& p)
> {
> throw (Yunexpected (&p));

I wonder if this is going to work. An exception is a temporary object.
You are saving an address of a temporary, but I strongly suspect
Network_exception object will be destroyed as soon as throwY exits (by
throwing another exception), at which point your Yunexpected instance
will hold a dangling pointer. Unless of course Yunexpected's constructor
allocates a copy of its parameter on the heap and saves a pointer to
that copy, or otherwise extracts and saves off some information from its
parameter before it's destroyed.

> } catch (...)
> {
> throw (Yunexpected (0));
> }
> }
> [/Code]

Note that you've entered unexpected() handler in the first place because
some function has thrown an exception that wasn't on its exception
specification list. Your handler throws another exception, Yunexpected.
At this point, one of three things can happen:
a) the function's exception specification lists Yunexpected. In this
case, execution continues as if the function had thrown Yunexpected from
the beginning.
b) the function's exception specification doesn't list Yunexpected, but
does list std::bad_exception. In this case, execution continues as if
the function had thrown bad_exception
c) Neither Yunexpected nor bad_exception are listed in the function's
exception specification. In this case, the program calls terminate().

This means that, since the point of throwY handler seems to be to
convert all unexpected exceptions to Yunexpected wrapper, every function
in your program that has exception specification at all should mention
Yunexpected in it. Otherwise your handler is pointless.


Finally, it should be noted that many (most?) C++ experts believe that
exception specifications, as specified in the C++ standard, are a
mistake and should not be used. See for example

http://www.gotw.ca/publications/mill22.htm

--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925



Re: unexpected exception handler by George

George
Tue Jan 08 08:08:01 CST 2008

Thanks Igor,


Great!

About your below comments, I agree and I have checked again the the code is
the same as Bjarne's code in the book -- I have not made any typo. :-)

BTW: how do you think we should correct the code? Could you provide some
correct code please?

> I wonder if this is going to work. An exception is a temporary object.
> You are saving an address of a temporary, but I strongly suspect
> Network_exception object will be destroyed as soon as throwY exits (by
> throwing another exception), at which point your Yunexpected instance
> will hold a dangling pointer. Unless of course Yunexpected's constructor
> allocates a copy of its parameter on the heap and saves a pointer to
> that copy, or otherwise extracts and saves off some information from its
> parameter before it's destroyed.


regards,
George

"Igor Tandetnik" wrote:

> "George" <George@discussions.microsoft.com> wrote in message
> news:7B351A53-4DBC-43ED-874C-C073E038B899@microsoft.com
> > This question is about when it is allowed to call throw to re-throw
> > exception -- make the exception re-throw.
> >
> > I can only think of two situations,
> >
> > 1. in catch block of an exception;
> > 2. in unexpected handler.
>
> Any function can contain a "throw;" statement. Such a function can be
> called from a catch clause (or from unexpected() handler), directly or
> indirectly:
>
> void rethrow() { throw; }
>
> try {...}
> catch (const exception&) { rethrow(); }
>
> If "throw;" statement is encountered while no exception is caught, the
> program calls terminate().
>
> > For (2), in unexpected handler, since the input parameter is null, so
> > in order to get the exception information, we need to re-throw it and
> > catch it to get exception informaiton.
> >
> > Is my understanding correct?
>
> Sounds about right.
>
> > Here is some pseudo code from Bjarne's
> > book.
> >
> > [Code]
> > // suppose throwY is unexpcted handler
> > void throwY() throw (Yunexpected)
> > {
> > try{
> > throw; // have to re-throw and catch in order to get exception
> > information since current input parameter is null and has no exception
> > information, my understanding correct?
> > } catch (Network_exception& p)
> > {
> > throw (Yunexpected (&p));
>
> I wonder if this is going to work. An exception is a temporary object.
> You are saving an address of a temporary, but I strongly suspect
> Network_exception object will be destroyed as soon as throwY exits (by
> throwing another exception), at which point your Yunexpected instance
> will hold a dangling pointer. Unless of course Yunexpected's constructor
> allocates a copy of its parameter on the heap and saves a pointer to
> that copy, or otherwise extracts and saves off some information from its
> parameter before it's destroyed.
>
> > } catch (...)
> > {
> > throw (Yunexpected (0));
> > }
> > }
> > [/Code]
>
> Note that you've entered unexpected() handler in the first place because
> some function has thrown an exception that wasn't on its exception
> specification list. Your handler throws another exception, Yunexpected.
> At this point, one of three things can happen:
> a) the function's exception specification lists Yunexpected. In this
> case, execution continues as if the function had thrown Yunexpected from
> the beginning.
> b) the function's exception specification doesn't list Yunexpected, but
> does list std::bad_exception. In this case, execution continues as if
> the function had thrown bad_exception
> c) Neither Yunexpected nor bad_exception are listed in the function's
> exception specification. In this case, the program calls terminate().
>
> This means that, since the point of throwY handler seems to be to
> convert all unexpected exceptions to Yunexpected wrapper, every function
> in your program that has exception specification at all should mention
> Yunexpected in it. Otherwise your handler is pointless.
>
>
> Finally, it should be noted that many (most?) C++ experts believe that
> exception specifications, as specified in the C++ standard, are a
> mistake and should not be used. See for example
>
> http://www.gotw.ca/publications/mill22.htm
>
> --
> With best wishes,
> Igor Tandetnik
>
> With sufficient thrust, pigs fly just fine. However, this is not
> necessarily a good idea. It is hard to be sure where they are going to
> land, and it could be dangerous sitting under them as they fly
> overhead. -- RFC 1925
>
>
>

Re: unexpected exception handler by Igor

Igor
Tue Jan 08 08:19:25 CST 2008

"George" <George@discussions.microsoft.com> wrote in message
news:B58E8128-5185-4574-9543-C25503F5A695@microsoft.com
> BTW: how do you think we should correct the code?

I think we should avoid exception specifications, in which case we
wouldn't care about unexpected() handler.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925



Re: unexpected exception handler by George

George
Tue Jan 08 08:31:07 CST 2008

Thanks Igor,


I hear some points to support exception specification is because, only if
developer could clearly list all the possible exceptions a function may
thrown, it is well designed function -- all exception situations are thought.

If we do not have exception specification, and simply catch(...), there may
be some exceptions we (developer) never thought of in design/implementation.

How do you comment those points?


regards,
George

"Igor Tandetnik" wrote:

> "George" <George@discussions.microsoft.com> wrote in message
> news:B58E8128-5185-4574-9543-C25503F5A695@microsoft.com
> > BTW: how do you think we should correct the code?
>
> I think we should avoid exception specifications, in which case we
> wouldn't care about unexpected() handler.
> --
> With best wishes,
> Igor Tandetnik
>
> With sufficient thrust, pigs fly just fine. However, this is not
> necessarily a good idea. It is hard to be sure where they are going to
> land, and it could be dangerous sitting under them as they fly
> overhead. -- RFC 1925
>
>
>

Re: unexpected exception handler by Igor

Igor
Tue Jan 08 13:30:39 CST 2008

George <George@discussions.microsoft.com> wrote:
> I hear some points to support exception specification is because,
> only if developer could clearly list all the possible exceptions a
> function may thrown, it is well designed function -- all exception
> situations are thought.

List them in a comment next to the function declaration, or in the
documentation.

Realize that the compiler has to actually generate code to enforce
exception specification at runtime. If you know your function never
throws exceptions other than those on the list, by writing an exception
specification you force the compiler to generate dead code that you know
will never run. And if you know your function _will_ throw exceptions
outside the list, then what's the point of putting in an exception
specification that's essentially a lie?

> If we do not have exception specification, and simply catch(...),
> there may be some exceptions we (developer) never thought of in
> design/implementation.

If there are exceptions you didn't think of, then you can't clearly list
all the possible exceptions a function may throw. By your own
definition, such a function is not well designed. So go back and design
it better.

I don't see how catch(...) is helpful. What are you going to do in such
a handler, other than perhaps some cleanup and then rethrow?
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925



Re: unexpected exception handler by Ben

Ben
Tue Jan 08 13:53:12 CST 2008


"Igor Tandetnik" <itandetnik@mvps.org> wrote in message
news:OfFBs0iUIHA.4712@TK2MSFTNGP04.phx.gbl...
> George <George@discussions.microsoft.com> wrote:
>> I hear some points to support exception specification is because,
>> only if developer could clearly list all the possible exceptions a
>> function may thrown, it is well designed function -- all exception
>> situations are thought.
>
> List them in a comment next to the function declaration, or in the
> documentation.
>
> Realize that the compiler has to actually generate code to enforce
> exception specification at runtime. If you know your function never throws
> exceptions other than those on the list, by writing an exception
> specification you force the compiler to generate dead code that you know
> will never run. And if you know your function _will_ throw exceptions
> outside the list, then what's the point of putting in an exception
> specification that's essentially a lie?
>
>> If we do not have exception specification, and simply catch(...),
>> there may be some exceptions we (developer) never thought of in
>> design/implementation.
>
> If there are exceptions you didn't think of, then you can't clearly list
> all the possible exceptions a function may throw. By your own definition,
> such a function is not well designed. So go back and design it better.

Also, providing an exception specification doesn't do much of anything
besides making
catch (bad_exception) an alternate syntax for catch (...)

>
> I don't see how catch(...) is helpful. What are you going to do in such a
> handler, other than perhaps some cleanup and then rethrow?
> --
> With best wishes,
> Igor Tandetnik
>
> With sufficient thrust, pigs fly just fine. However, this is not
> necessarily a good idea. It is hard to be sure where they are going to
> land, and it could be dangerous sitting under them as they fly
> overhead. -- RFC 1925
>
>



Re: unexpected exception handler by George

George
Tue Jan 08 21:35:01 CST 2008

Thanks Igor,


Do you think from technical point of view, it is possible to list all the
exceptions? I am not sure whether there are any potential exceptions at
runtime which we do not know at development time.


regards,
George

"Igor Tandetnik" wrote:

> George <George@discussions.microsoft.com> wrote:
> > I hear some points to support exception specification is because,
> > only if developer could clearly list all the possible exceptions a
> > function may thrown, it is well designed function -- all exception
> > situations are thought.
>
> List them in a comment next to the function declaration, or in the
> documentation.
>
> Realize that the compiler has to actually generate code to enforce
> exception specification at runtime. If you know your function never
> throws exceptions other than those on the list, by writing an exception
> specification you force the compiler to generate dead code that you know
> will never run. And if you know your function _will_ throw exceptions
> outside the list, then what's the point of putting in an exception
> specification that's essentially a lie?
>
> > If we do not have exception specification, and simply catch(...),
> > there may be some exceptions we (developer) never thought of in
> > design/implementation.
>
> If there are exceptions you didn't think of, then you can't clearly list
> all the possible exceptions a function may throw. By your own
> definition, such a function is not well designed. So go back and design
> it better.
>
> I don't see how catch(...) is helpful. What are you going to do in such
> a handler, other than perhaps some cleanup and then rethrow?
> --
> With best wishes,
> Igor Tandetnik
>
> With sufficient thrust, pigs fly just fine. However, this is not
> necessarily a good idea. It is hard to be sure where they are going to
> land, and it could be dangerous sitting under them as they fly
> overhead. -- RFC 1925
>
>
>

Re: unexpected exception handler by Igor

Igor
Tue Jan 08 22:30:22 CST 2008

"George" <George@discussions.microsoft.com> wrote in message
news:0226EB22-2ECE-4FA2-A915-7FD93942EB05@microsoft.com
> Do you think from technical point of view, it is possible to list all
> the exceptions?

Yes and no. Generic library functions (like STL algorithms) can't really
do that, but they should a) carefully document exceptions they may
produce on their own, and under what conditions, and b) propagate
unchanged any exceptions that emanate from user-provided callbacks
(predicates, comparators, copy constructors, assignment operators and
the like). This allows the calling code to reliably know what exceptions
a library function may throw in the caller's particular circumstances.

On the other hand, high-level business logic functions can document all
exceptions they may throw. Functions at a module's boundary, at least,
should do that. They form the API for the module, and error handling
strategy is part of the API and should be documented.

> I am not sure whether there are any potential
> exceptions at runtime which we do not know at development time.

You sound as if exceptions just happen unpredictably, like earthquakes
or tornadoes. Computers are deterministic state machines. Exceptions
don't occur at random, they are thrown by some piece of code in your
application. You are basically saying that you have no idea what your
code is doing. That's not a good way to develop software.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925



Re: unexpected exception handler by George

George
Tue Jan 08 23:17:01 CST 2008

Thanks for your advice, Igor!


My question is answered.


regards,
George

"Igor Tandetnik" wrote:

> "George" <George@discussions.microsoft.com> wrote in message
> news:0226EB22-2ECE-4FA2-A915-7FD93942EB05@microsoft.com
> > Do you think from technical point of view, it is possible to list all
> > the exceptions?
>
> Yes and no. Generic library functions (like STL algorithms) can't really
> do that, but they should a) carefully document exceptions they may
> produce on their own, and under what conditions, and b) propagate
> unchanged any exceptions that emanate from user-provided callbacks
> (predicates, comparators, copy constructors, assignment operators and
> the like). This allows the calling code to reliably know what exceptions
> a library function may throw in the caller's particular circumstances.
>
> On the other hand, high-level business logic functions can document all
> exceptions they may throw. Functions at a module's boundary, at least,
> should do that. They form the API for the module, and error handling
> strategy is part of the API and should be documented.
>
> > I am not sure whether there are any potential
> > exceptions at runtime which we do not know at development time.
>
> You sound as if exceptions just happen unpredictably, like earthquakes
> or tornadoes. Computers are deterministic state machines. Exceptions
> don't occur at random, they are thrown by some piece of code in your
> application. You are basically saying that you have no idea what your
> code is doing. That's not a good way to develop software.
> --
> With best wishes,
> Igor Tandetnik
>
> With sufficient thrust, pigs fly just fine. However, this is not
> necessarily a good idea. It is hard to be sure where they are going to
> land, and it could be dangerous sitting under them as they fly
> overhead. -- RFC 1925
>
>
>

Re: unexpected exception handler by Ben

Ben
Wed Jan 09 08:13:39 CST 2008

> You sound as if exceptions just happen unpredictably, like earthquakes or
> tornadoes. Computers are deterministic state machines. Exceptions don't
> occur at random, they are thrown by some piece of code in your
> application. You are basically saying that you have no idea what your

That's not accurate. Computers have a lot of non-determinism. Some, like
timing of hardware I/O, the software should expect and process without
exceptions. Others, like network or disk checksum failures, the software
should expect and may generate exceptions for internal flow control. But
yet others, like memory bit errors, could occur asynchronously and are
reported by a exception generated by hardware, randomly and from the level
of abstraction of application software, perfectly so.

> code is doing. That's not a good way to develop software.
> --
> With best wishes,
> Igor Tandetnik
>
> With sufficient thrust, pigs fly just fine. However, this is not
> necessarily a good idea. It is hard to be sure where they are going to
> land, and it could be dangerous sitting under them as they fly
> overhead. -- RFC 1925
>



Re: unexpected exception handler by George

George
Wed Jan 09 08:36:07 CST 2008

Good point, Ben!


For the file stream I/O related (file stream read, write, seek, etc.), in
STL, are there any general base exception class which we could catch to make
code at least could be notified such errors?


regards,
George

"Ben Voigt [C++ MVP]" wrote:

> > You sound as if exceptions just happen unpredictably, like earthquakes or
> > tornadoes. Computers are deterministic state machines. Exceptions don't
> > occur at random, they are thrown by some piece of code in your
> > application. You are basically saying that you have no idea what your
>
> That's not accurate. Computers have a lot of non-determinism. Some, like
> timing of hardware I/O, the software should expect and process without
> exceptions. Others, like network or disk checksum failures, the software
> should expect and may generate exceptions for internal flow control. But
> yet others, like memory bit errors, could occur asynchronously and are
> reported by a exception generated by hardware, randomly and from the level
> of abstraction of application software, perfectly so.
>
> > code is doing. That's not a good way to develop software.
> > --
> > With best wishes,
> > Igor Tandetnik
> >
> > With sufficient thrust, pigs fly just fine. However, this is not
> > necessarily a good idea. It is hard to be sure where they are going to
> > land, and it could be dangerous sitting under them as they fly
> > overhead. -- RFC 1925
> >
>
>
>

Re: unexpected exception handler by Ben

Ben
Wed Jan 09 08:45:39 CST 2008


"George" <George@discussions.microsoft.com> wrote in message
news:EFDBBBF5-2152-4B57-A1F8-2173E66DE027@microsoft.com...
> Good point, Ben!
>
>
> For the file stream I/O related (file stream read, write, seek, etc.), in
> STL, are there any general base exception class which we could catch to
> make
> code at least could be notified such errors?

Exceptions outside software control are all OS exceptions, you can set up
handlers using __try/__catch/__finally SEH keywords or you can use the
set_se_translator function to convert these into a C++ exception type of
your choosing.

>
>
> regards,
> George
>
> "Ben Voigt [C++ MVP]" wrote:
>
>> > You sound as if exceptions just happen unpredictably, like earthquakes
>> > or
>> > tornadoes. Computers are deterministic state machines. Exceptions don't
>> > occur at random, they are thrown by some piece of code in your
>> > application. You are basically saying that you have no idea what your
>>
>> That's not accurate. Computers have a lot of non-determinism. Some,
>> like
>> timing of hardware I/O, the software should expect and process without
>> exceptions. Others, like network or disk checksum failures, the software
>> should expect and may generate exceptions for internal flow control. But
>> yet others, like memory bit errors, could occur asynchronously and are
>> reported by a exception generated by hardware, randomly and from the
>> level
>> of abstraction of application software, perfectly so.
>>
>> > code is doing. That's not a good way to develop software.
>> > --
>> > With best wishes,
>> > Igor Tandetnik
>> >
>> > With sufficient thrust, pigs fly just fine. However, this is not
>> > necessarily a good idea. It is hard to be sure where they are going to
>> > land, and it could be dangerous sitting under them as they fly
>> > overhead. -- RFC 1925
>> >
>>
>>
>>



Re: unexpected exception handler by George

George
Wed Jan 09 08:59:06 CST 2008

Thanks Ben,


1.

I think for I/O fail, even if H/W fail, it should be reflected into some
software exception, like ios_base::fail or something, which we should catch.
So, it should be possible to write code to catch all I/O exceptions -- there
is no unpredicted errors.

2.

For set_se_translator, similar to set_unexpected, it is used for the code
which is not properly designed and implemented -- the developer of the code
never through of such types of exception will be thrown, so set_se_translator
is used as final fence.

These are my points. If I am wrong, please feel free to correct me. I am not
an expert. :-)


regards,
George

"Ben Voigt [C++ MVP]" wrote:

>
> "George" <George@discussions.microsoft.com> wrote in message
> news:EFDBBBF5-2152-4B57-A1F8-2173E66DE027@microsoft.com...
> > Good point, Ben!
> >
> >
> > For the file stream I/O related (file stream read, write, seek, etc.), in
> > STL, are there any general base exception class which we could catch to
> > make
> > code at least could be notified such errors?
>
> Exceptions outside software control are all OS exceptions, you can set up
> handlers using __try/__catch/__finally SEH keywords or you can use the
> set_se_translator function to convert these into a C++ exception type of
> your choosing.
>
> >
> >
> > regards,
> > George
> >
> > "Ben Voigt [C++ MVP]" wrote:
> >
> >> > You sound as if exceptions just happen unpredictably, like earthquakes
> >> > or
> >> > tornadoes. Computers are deterministic state machines. Exceptions don't
> >> > occur at random, they are thrown by some piece of code in your
> >> > application. You are basically saying that you have no idea what your
> >>
> >> That's not accurate. Computers have a lot of non-determinism. Some,
> >> like
> >> timing of hardware I/O, the software should expect and process without
> >> exceptions. Others, like network or disk checksum failures, the software
> >> should expect and may generate exceptions for internal flow control. But
> >> yet others, like memory bit errors, could occur asynchronously and are
> >> reported by a exception generated by hardware, randomly and from the
> >> level
> >> of abstraction of application software, perfectly so.
> >>
> >> > code is doing. That's not a good way to develop software.
> >> > --
> >> > With best wishes,
> >> > Igor Tandetnik
> >> >
> >> > With sufficient thrust, pigs fly just fine. However, this is not
> >> > necessarily a good idea. It is hard to be sure where they are going to
> >> > land, and it could be dangerous sitting under them as they fly
> >> > overhead. -- RFC 1925
> >> >
> >>
> >>
> >>
>
>
>

Re: unexpected exception handler by Ben

Ben
Wed Jan 09 10:50:40 CST 2008


"George" <George@discussions.microsoft.com> wrote in message
news:C4A8B71D-CDC3-4DC3-BB39-232F247128CD@microsoft.com...
> Thanks Ben,
>
>
> 1.
>
> I think for I/O fail, even if H/W fail, it should be reflected into some
> software exception, like ios_base::fail or something, which we should
> catch.
> So, it should be possible to write code to catch all I/O exceptions --
> there
> is no unpredicted errors.

That's not really a hardware failure. It's the hardware or driver correctly
reporting a result which indicates failure of an operation. For example,
out of disk space or file not found can occur with no hardware errors at
all.

>
> 2.
>
> For set_se_translator, similar to set_unexpected, it is used for the code
> which is not properly designed and implemented -- the developer of the
> code
> never through of such types of exception will be thrown, so
> set_se_translator
> is used as final fence.
>
> These are my points. If I am wrong, please feel free to correct me. I am
> not
> an expert. :-)

Hardware "exceptions" will be translated by Windows into OS "structured"
exceptions. If you want to see C++ exceptions for these you will need to
use set_se_translator. Some of these hardware exceptions are caused by bad
code but not all. Sometimes exceptions in libraries written in other
languages or other C++ compilers would probably also be represented as a
structured exception.

If the hardware didn't have a failure, but the data delivered was bad
somehow, typically the library processing it will return a failure code or
C++ exception, and then you would not need set_se_translator.

Of course, the types of hardware failure that generate exceptions are
possibly so severe that your exception handler won't work properly anyway.

>
>
> regards,
> George
>
> "Ben Voigt [C++ MVP]" wrote:
>
>>
>> "George" <George@discussions.microsoft.com> wrote in message
>> news:EFDBBBF5-2152-4B57-A1F8-2173E66DE027@microsoft.com...
>> > Good point, Ben!
>> >
>> >
>> > For the file stream I/O related (file stream read, write, seek, etc.),
>> > in
>> > STL, are there any general base exception class which we could catch to
>> > make
>> > code at least could be notified such errors?
>>
>> Exceptions outside software control are all OS exceptions, you can set up
>> handlers using __try/__catch/__finally SEH keywords or you can use the
>> set_se_translator function to convert these into a C++ exception type of
>> your choosing.
>>
>> >
>> >
>> > regards,
>> > George
>> >
>> > "Ben Voigt [C++ MVP]" wrote:
>> >
>> >> > You sound as if exceptions just happen unpredictably, like
>> >> > earthquakes
>> >> > or
>> >> > tornadoes. Computers are deterministic state machines. Exceptions
>> >> > don't
>> >> > occur at random, they are thrown by some piece of code in your
>> >> > application. You are basically saying that you have no idea what
>> >> > your
>> >>
>> >> That's not accurate. Computers have a lot of non-determinism. Some,
>> >> like
>> >> timing of hardware I/O, the software should expect and process without
>> >> exceptions. Others, like network or disk checksum failures, the
>> >> software
>> >> should expect and may generate exceptions for internal flow control.
>> >> But
>> >> yet others, like memory bit errors, could occur asynchronously and are
>> >> reported by a exception generated by hardware, randomly and from the
>> >> level
>> >> of abstraction of application software, perfectly so.
>> >>
>> >> > code is doing. That's not a good way to develop software.
>> >> > --
>> >> > With best wishes,
>> >> > Igor Tandetnik
>> >> >
>> >> > With sufficient thrust, pigs fly just fine. However, this is not
>> >> > necessarily a g