------------------------------------------------------------------ -- -- NAME: ERROR_ROUTINES - BODY -- DISCREPANCY REPORTS: ------------------------------------------------------------------ -- file: error_routines_2a_b.ada -- level: 2a, 2b, 2c with AVAILABLE_WS_TYPES; with GKS_OPERATING_STATE_LIST; with GKS_STATE_LIST; with GKS_CONTROL; with WS_CONTROL; with INQ_WS_STATE_LIST_MA; with SEGMENTS; with TEXT_IO; with GKS_ERROR_STATE_LIST; with GKS_ERROR_STATE_LIST; use GKS_OPERATING_STATE_LIST; package body ERROR_ROUTINES is -- This is the package body providing the procedures -- for GKS error handling. procedure EMERGENCY_CLOSE_GKS is -- This procedure closes GKS in case of a non-recoverable -- error and still saves as much information as possible. -- All workstations are updated (by calling GKS procedure -- UPDATE_WS). All active workstations are deactivated -- (by calling GKS procedure DEACTIVATE_WS). All WS are -- closed (by calling GKS procedure CLOSE_WS). And GKS is -- closed (by calling CLOSE_GKS). function "=" (LEFT,RIGHT : in WS_IDS.LIST_OF) return BOOLEAN renames WS_IDS."="; ERROR_INDICATOR : ERROR_NUMBER; CONNECTION : VARIABLE_CONNECTION_ID; TYPE_OF_WS : WS_TYPE; begin if CURRENT_OPERATING_STATE /= GKCL then if CURRENT_OPERATING_STATE = SGOP then SEGMENTS.CLOSE_SEGMENT; end if; if GKS_STATE_LIST.LIST_OF_ACTIVE_WS /= WS_IDS.NULL_LIST then CURRENT_OPERATING_STATE := WSAC; -- Change the current operating state to a valid state -- for the procedures UPDATE_WS and DEACTIVATE_WS. for INDEX in reverse POSITIVE(1)..POSITIVE(WS_IDS. SIZE_OF_LIST(GKS_STATE_LIST.LIST_OF_ACTIVE_WS)) loop -- Update all open WS (except WISS workstations). INQ_WS_STATE_LIST_MA.INQ_WS_CONNECTION_AND_TYPE (WS_IDS.LIST_ELEMENT(INDEX, GKS_STATE_LIST. LIST_OF_ACTIVE_WS), ERROR_INDICATOR, CONNECTION, TYPE_OF_WS); if TYPE_OF_WS /= AVAILABLE_WS_TYPES.WISS_TYPE then WS_CONTROL.UPDATE_WS(WS_IDS.LIST_ELEMENT(INDEX, GKS_STATE_LIST.LIST_OF_ACTIVE_WS),PERFORM); end if; -- Deactivate all active WS. WS_CONTROL.DEACTIVATE_WS(WS_IDS.LIST_ELEMENT(INDEX, GKS_STATE_LIST.LIST_OF_ACTIVE_WS)); end loop; end if; if GKS_STATE_LIST.LIST_OF_OPEN_WS /= WS_IDS.NULL_LIST then CURRENT_OPERATING_STATE := WSOP; -- To ensure that the current operating state is in a valid -- state for the procedure CLOSE_WS. for INDEX in reverse POSITIVE(1).. POSITIVE(WS_IDS. SIZE_OF_LIST(GKS_STATE_LIST.LIST_OF_OPEN_WS)) loop -- Close all open WS. WS_CONTROL.CLOSE_WS(WS_IDS.LIST_ELEMENT(INDEX, GKS_STATE_LIST.LIST_OF_OPEN_WS)); end loop; end if; -- Close GKS. CURRENT_OPERATING_STATE := GKOP; -- To ensure that the current operating state is in a valid -- state for the procedure CLOSE_GKS. GKS_CONTROL.CLOSE_GKS; end if; end EMERGENCY_CLOSE_GKS; procedure ERROR_LOGGING (ERROR_INDICATOR : in ERROR_NUMBER; GKS_FUNCTION : in STRING; ERROR_FILE : in STRING := DEFAULT_ERROR_FILE) is -- This procedure writes the error number and the GKS function -- name detecting the error to the error file (created when the -- GKS function OPEN_GKS was called) using the I/O facilities of -- TEXT_IO. -- -- ERROR_INDICATOR - This is the error indicator. Its numeric value -- represents the type of error being logged. -- GKS_FUNCTION - This is a string type. Its value is the name of the -- procedure in which the error being logged occurred. -- ERROR_FILE - Not supported in this implementation. begin -- Write the error indicator and the subprogram name to the -- error file. if GKS_OPERATING_STATE_LIST.CURRENT_OPERATING_STATE = GKCL then if not TEXT_IO.IS_OPEN(GKS_ERROR_STATE_LIST.ERROR_DATA) then TEXT_IO.CREATE (GKS_ERROR_STATE_LIST.ERROR_DATA, TEXT_IO.OUT_FILE, GKS_TYPES.DEFAULT_ERROR_FILE); end if; TEXT_IO.NEW_LINE(GKS_ERROR_STATE_LIST.ERROR_DATA); TEXT_IO.PUT(GKS_ERROR_STATE_LIST.ERROR_DATA,"GKS ERROR NUMBER "); TEXT_IO.PUT(GKS_ERROR_STATE_LIST.ERROR_DATA, ERROR_NUMBER'IMAGE(ERROR_INDICATOR)); TEXT_IO.PUT(GKS_ERROR_STATE_LIST.ERROR_DATA," OCCURRED IN "); TEXT_IO.PUT(GKS_ERROR_STATE_LIST.ERROR_DATA, GKS_FUNCTION); TEXT_IO.NEW_LINE(GKS_ERROR_STATE_LIST.ERROR_DATA); TEXT_IO.CLOSE(GKS_ERROR_STATE_LIST.ERROR_DATA); else TEXT_IO.NEW_LINE(GKS_ERROR_STATE_LIST.ERROR_DATA); TEXT_IO.PUT(GKS_ERROR_STATE_LIST.ERROR_DATA,"GKS ERROR NUMBER "); TEXT_IO.PUT(GKS_ERROR_STATE_LIST.ERROR_DATA, ERROR_NUMBER'IMAGE(ERROR_INDICATOR)); TEXT_IO.PUT(GKS_ERROR_STATE_LIST.ERROR_DATA," OCCURRED IN "); TEXT_IO.PUT(GKS_ERROR_STATE_LIST.ERROR_DATA, GKS_FUNCTION); TEXT_IO.NEW_LINE(GKS_ERROR_STATE_LIST.ERROR_DATA); end if; end ERROR_LOGGING; end ERROR_ROUTINES;