micropython

docs/exceptions.txt

234:77038806cb40
2009-06-01 Paul Boddie Moved context verification back into the invocation code, as opposed to residing in the function body code. This is required because keyword arguments need to operate on adjusted frames, and such adjustments must therefore occur because keyword arguments are stored in their invocation frames. Renamed CheckClassContext to the more general CheckClass instruction. Made AdjustFrame operate on invocation frames again. Introduced explicit tests for class invocation since instantiators require an extra slot for each new instance. Fixed the "if" statement to employ conversion of expression results to boolean values. Split and improved test programs.
     1 Exception Handling
     2 ==================
     3 
     4 Active Exceptions
     5 =================
     6 
     7 When an exception is raised, an exception instance is defined as the active
     8 exception. This active exception remains in force until either a new exception
     9 is raised in any handling of the exception, or upon exit of a handler where
    10 the active exception has been caught (thus resetting the active exception).
    11 
    12 Instructions
    13 ------------
    14 
    15 StoreException records the current value reference using the exception
    16 register.
    17 
    18 LoadException obtains the current exception and puts it in the value register.
    19 
    20 CheckException checks the current exception against a class referenced by the
    21 current value.
    22 
    23 ClearException resets the exception register.
    24 
    25 Handlers
    26 ========
    27 
    28 An exception handler stack is defined such that when a try...except or
    29 try...finally block is entered, a new handler is defined.
    30 
    31 When an exception is raised, the program jumps to the most recently defined
    32 handler. Inside the handler, the stack entry for the handler will be removed.
    33 
    34 Depending on the nature of the handler and whether the exception is handled,
    35 the program may jump to the next most recent handler, and so on.
    36 
    37 If no handler is defined when an exception is raised or re-raised, the program
    38 should terminate. This might be done by having a "handler #0" which explicitly
    39 terminates the program.
    40 
    41 Instructions
    42 ------------
    43 
    44 PushHandler(block) defines an active handler at the location indicated by the
    45 given block.
    46 
    47 PopHandler removes the active handler at or after the location indicated by
    48 the previously given block.