Improve error handling in serve script