Check if post belongs to any category

get_the_terms return and error on failure. So before your foreach loop check for the error and only run it if there is none, using is_wp_error.

<?php 
$myterms = get_the_terms( $post->ID, 'portfolio_category' );

if( !is_wp_error( $myterms ) )
    foreach( $myterms as $myterm )
        echo $myterm->slug . '<br />';
?>