Improve try statement in main().