Added error handling for post creation