I have the following:
foreach( $this_post_terms as $term ) :
$thiscat = get_term_by( 'slug', $term->slug, 'categories_whatever' );
echo $thiscat->ID;
endforeach;
The last line throws an error, Undefined property: stdClass::$ID.
What's weird to me is that
echo $thiscat->name;
works, doesn't throw any error.