Refactor exit(EXIT_FAILURE) calls to throw exceptions (e.g., std::runtime_error) for better error handling and testability.
- Current code uses exit(EXIT_FAILURE) which terminates the process abruptly without cleanup - Exceptions allow callers to catch and handle errors gracefully - Easier to write unit tests with EXPECT_THROW