Improve error handling of serve script