Re: unexpected exception handler



Hi Tamas,


I have two more comments,

1.

exceptions. 3rd party libraries without source code don't throw either,

Why 3rd party without source codes can not throw exception? Visual Studio
STL lib does not provide source codes, but it still throws exception.

2.

You can't throw an exception from a DLL

Why we can not throw exception throw a DLL? Windows SDK, STL, etc. are all
provided as DLL and they could throw exception as API specification described.


regards,
George

"Tamas Demjen" wrote:

George wrote:

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.

It is very unlikely. The operating system itself can't throw C++
exceptions. 3rd party libraries without source code don't throw either,
because in C++ you can't throw an exception in a binary portable way.
You can't throw an exception from a DLL, and if it's a LIB, it's almost
always written in native C. In order to link a static C++ LIB to your
project, it has to use the same compiler, the same STL version, and the
same compiler settings that your main project. For this reason 3rd party
vendors almost never distribute C++ libraries in LIB format.

In other languages, such as Delphi, Java, C#, it is fairly common that a
3rd party library without source code throws. Not in C++.

A COM library may throw, but COM exceptions are marshaled. A COM
exception is not a C++ exception, only ATL turns them into C++
exceptions. This is something developers know about, though. Similarly,
a Web service can throw too, but a Web service exception is nothing more
than an XML tag, and only the XML parser turns it into a C++ exception.
Again, it's documented in the library.

STL and boost both can throw, but they come with full source code and
documentation. There should be no surprise there.

There are unexpected situations, such as access violations and division
by 0, but they're not C++ exceptions:
try
{
void* p = 0;
*p = 0;
}
catch(...)
{
// you normally can't catch this in VC++ 2005, 2008
}

So what remains is a mystery C++ LIB file from an unreliable source that
you have absolutely no knowledge of. That may throw without your
knowledge. But if you link that to your project, you are asking for
*major* trouble anyway. I would avoid doing that at all cost.

Tom

.



Relevant Pages

  • Re: Javascript Error Meaning
    ... It is an exception thrown by an internal component of Firefox. ... var nativeMethod = Components.lookupMethod(this.mUntrustedObject, ... an interface or an extension, maybe you have used this interface wrong. ... There is no way of telling unless you show some source code (please, ...
    (comp.lang.javascript)
  • RE: Strange LocalDataStoreSlot storage has been freed exception
    ... source code, it is not easy to find the root cause of the issue. ... Visual Studio to debug exception. ... In the Exceptions window, break when Common Language Runtime Exception ...
    (microsoft.public.dotnet.framework.clr)
  • Re: System.Net.Mail.SmtpClient MailClient message. How do u know if it was successful?
    ... Go here and download the source code. ... i'd throw an exception here, else you have no idea it didn't work. ... Can the mail classes be used without having a SMTP server running on ... public void SendEmail(string Sender, string Recipient, string Subject, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Ping from C/C++ doesnt work properly using either System() or popen()
    ... Portable practice, ... My rule of thumb is this: Without exception, ... As far as I am concerned, source code should be a special ... 10 minutes to find the function reference and see what that 1 was supposed ...
    (comp.os.linux.networking)
  • Re: Direct3D.InvalidCallException using Summer 04 update
    ... What is your application calling when the exception occurs? ... A call stack trace would help here, as would the source code. ... What is the error string/code provided by the exception? ...
    (microsoft.public.win32.programmer.directx.managed)