      $set mfoo ooctrl(+n)
       class-id. AccountExceptionHandler inherits from Base.

       class-control.
           AccountExceptionHandler is class "acexhand"
           Base is class "base"
           ExceptionManager is class "exptnmgr"
           Callback is class "callback"
           Account is class "account"
           SavingsAccount is class "saccount"
           HighRateAccount is class "haccount"
           CheckAccount is class "caccount"
           .
       working-storage section.
      * E000. Copyfile includes list of exception numbers
       copy "accinfo.cpy".
       class-object.

       method-id. "initializeHandlers".
       local-storage section.
       01 lsAccountErrorMethod     object reference.
       procedure division.
      *----E010. Create a callback for the exception handling method.
           invoke CallBack "new" using self z"onExceptionAccountError"
                             returning lsAccountErrorMethod
      *----E020. Register the handler against each of the account types.
           invoke ExceptionManager "register" using account
                                                    lsAccountErrorMethod
           invoke ExceptionManager "register" using CheckAccount
                                                    lsAccountErrorMethod
           invoke ExceptionManager "register" using SavingsAccount
                                                    lsAccountErrorMethod
           invoke ExceptionManager "register" using HighRateAccount
                                                    lsAccountErrorMethod
           exit method.
       end method "initializeHandlers".

       method-id. "onExceptionAccountError".
       local-storage section.
       01 lsOffset                 pic x(4) comp-5.
       01 lsException              pic x(4) comp-5.
       01 lsMessage                object reference.

       linkage section.
       01 lnkException             pic x(4) comp-5.
       01 lnkErrorObject           object reference.
       01 lnkReturnObject          object reference.

       procedure division using lnkErrorObject lnkException
                      returning lnkReturnObject.
      *----E030. Return a null object reference from the error handler
           set lnkReturnObject to null
      *----E040. Return the error offset registered against account
      *    files.
           invoke ExceptionManager "queryMessageFile"
                                       using "bank" "account"
                                   returning lsOffset
      *----E050. Get the exception number by subtracting the offset
           subtract lsOffset from lnkException giving lsException
      *----E060. This handler only knows how to deal with exception
      *    numbers 1 to 3. Higher numbers must be dealt with by a
      *    different handler.
           if lsException < 4
      *--------E070. Fetch the exception message and display it.
               invoke ExceptionManager "errorMessage" using lnkException
                                                  returning lsMessage
               invoke lsMessage "display"
           else
      *--------E080. This is an exception the application cannot handle.
      *        The exception is reraised and unless trapped
      *        elsewhere terminates the application.
               invoke super "raiseException" using lnkException
                                         returning lnkReturnObject
           end-if
           exit method.
       end method "onExceptionAccountError".
       end class-object.
       end class AccountExceptionHandler.
