# reraise and other error-handling

slayer@kaiwan.com (slayer@kaiwan.com)
Fri, 2 Aug 1996 15:59:31 PDT

- Messages sorted by:[ date ][ thread ][ subject ][ author ]

    At 04:11 PM 8/2/96 PDT, Adams, Charles wrote:
    >I also noticed that a try..except..finally..endtry construct does not
    >compile.  It seems you can't mix the two kinds -- a "finally" statement
    >can't be seen in a construct when "except" statements are also present.  Was
    >this omission accidental or deliberate?
    >

    this was deliberate, here's what Pavel said to save the trouble of him
    having to answer again:
    ---

    Tom Meyer writes:
    > I've been playing a bit with the exception handlers in 1.8.0beta3, and
    > don't understand why I can't do the following:
    >   try
    >     <some code here>
    >   except
    >     <some exception>
    >   finally
    >     <Code to clean up in any case>
    >   endtry
    >
    > I can use either the EXCEPT or the FINALLY part in the try statement,
    > but can't use both.

    You can't do this because I didn't implement it that way and it would be
    difficult to fix it now.  Write something like that as follows:

            try
              try
                <some code here>
              except (...)
                <some handler>
              endtry
            finally
              <Code to clean up in any case>
            endtry

    I actually find this more readable, since it's more clear which of the EXCEPT
    and FINALLY parts is wrapped more tightly around the main TRY body.

            Pavel