Handling duplicates with wp_insert_term()

if ( is_wp_error($term_id) ) {

  // oops WP_Error obj returned, so the term existed prior
  // echo $term_id->get_error_message();
}

See if that works for you.