Format script as library (handle exceptions, logger)