Commit f9182f75 authored by Massimo Costantini's avatar Massimo Costantini
Browse files

Added wrapper

parent 339ea6a2
Loading
Loading
Loading
Loading
+18 −9
Original line number Diff line number Diff line
@@ -210,10 +210,16 @@ const IVOA_main = () => async (IO) => {
 *
 * Functional signature: () -> IO ()
 *
 * @returns {(IO) => Promise<void>} - A CPS IO action that launches the main TAP and DataLink server logic
 * @returns {(IO) => Promise<void>} - A CPS IO action that launches the server logic
 */
const mainExpression = () => IVOA_main();

/**
 * Handles top-level execution and exception reporting.
 *
 * Functional signature: () -> IO ()
 */
const mainWrapper = async () => {
  try {
    await performIO(mainExpression());
  } catch (e) {
@@ -223,3 +229,6 @@ try {
      throw e;
    }
  }
};

await mainWrapper();
+12 −6
Original line number Diff line number Diff line
@@ -261,17 +261,23 @@ def main_expression() -> Callable[[object], Awaitable[None]]:
    Wraps the program execution in a safe IO environment.

    Functional signature: () -> IO ()

    Returns:
        Callable[[object], Awaitable[None]]: A CPS IO action that launches the main TAP and DataLink server logic.
    """
    return ivoa_main()


if __name__ == "__main__":
async def main_wrapper():
    """
    Handles top-level execution and exception reporting.

    Functional signature: () -> IO ()
    """
    try:
        asyncio.run(perform_io(main_expression()))
        await perform_io(main_expression())
    except InternalError as e:
        asyncio.run(put_str("ERROR: " + str(e))(IO))
        await put_str("ERROR: " + str(e))(IO)
    except Exception as e:
        raise


if __name__ == "__main__":
    asyncio.run(main_wrapper())