Refactor error handling in NewControllerHandler()