$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID');
$comment_id = wp_new_comment( $commentdata );
-$comment = get_comment($comment_id);
+if ( ! $comment_id ) {
+ wp_die( __( "<strong>ERROR</strong>: The comment could not be saved. Please try again later." ) );
+}
+
+$comment = get_comment( $comment_id );
/**
* Perform other actions when comment cookies are set.