Re: unexpected exception handler
"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 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