Re: Oh boy, how did we miss this...

From: VBDis (vbdis_at_aol.com)
Date: 11/08/04


Date: 08 Nov 2004 08:14:32 GMT

Im Artikel <2v8cj5F2imqbrU1@uni-berlin.de>, Rob Kennedy <me3@privacy.net>
schreibt:

>> Except clauses catch *all* exceptions, even those raised by the OS (if
>ever)
>
>As far as Delphi is concerned, the things the OS raises are not
>exceptions. They are run-time errors.

I'm not sure how the system reports runtime errors to an application at all. Do
you know how this is done?

Now I've tried to explore the error handling, by dereferencing an nil pointer.
This error seems to trigger SEH immediately, but no handler responded because I
had intentionally excluded SysUtils. Finally the default exception handler
(ExceptionHandler) was entered, which called RtlUnwind so that the Finally
clauses could execute, then the program was terminated with a Halt.

According to these observations at least OS runtime errors initially are
exceptions, which trigger SEH. When SysUtils is included, then the OS
exceptions are translated into Delphi exceptions, with Delphi exception
objects, and SEH works as expected. When SysUtils is not included, then the
runtime error exceptions are not handled, and only the Finally clauses execute
during stack unwinding, before the application is halted.

>It's a subtle distinction, but at the language level, "except" clauses
>do not catch run-time errors. It's only underneath, at the
>implementation level, that the errors are caught. If they can't be
>converted to exceptions, then they are released again, so the non-RTL
>code never sees anything but Delphi exceptions.

You are right. When an exception doesn't have an associated exception object,
and no such object can be created by ExceptObjProc (GetExceptionObject), then
the exception only is caught in the default exception handler, which shuts down
the application.

>Exception classes are compared by *name*, not by address.

Oh, sorry, you are right.

DoDi



Relevant Pages

  • Re: The Debug Game: Russian Roulette
    ... Anyway I asked somebody else if he happened to have Delphi 6 installed... ... at exceptions and how unhandled exceptions made applications crash =D ... I still wonder if Delphi 6 had this excepting handling in place... ... > Skybuck;) ...
    (alt.comp.lang.borland-delphi)
  • Re: File or TStream?
    ... The Delphi 5 help doesn't give any indication of that limitation. ... > using IOResult vs. using exceptions? ... Existing C code may be ported easier when ...
    (comp.lang.pascal.delphi.misc)
  • Re: Oh boy, how did we miss this...
    ... >> Now I've tried to explore the error handling, ... >> This error seems to trigger SEH immediately, but no handler responded because I ... RaiseLastWin32Error to convert the API errors into Delphi exceptions. ...
    (comp.lang.pascal.delphi.misc)
  • Re: Exceptions (was: Typecast vs "as")
    ... inzwischen vielleicht ein Tool für Delphi Quelltexte? ... Im Ernst: Checked Exceptions gelten zu Recht als fehlgeschlagenes ... In Java geht das problemlos, ...
    (de.comp.lang.delphi.misc)
  • Re: More WTF
    ... TCollection, so he could have just called List.Clear to accomplish the same thing, but properly. ... Properly in the sense that it doesn't swallow exceptions and leak Count-i items, ... Delphi code should generally follow the 'cleanup can't fail idiom' that is popular in C++. ... Your coworker should be using Clear instead of a hand coded loop that leaks. ...
    (borland.public.delphi.non-technical)