Catchable fatal error on custom category post

You can wrap it in the same check used for $category:

<?php if (isset($term->term_id)) {
    echo '<a href="'.get_term_link($term).'">'.$term->name.'</a>';
} ?>

or check to make sure it is not an error object:

<?php if (!is_wp_error($term)) {
    echo '<a href="'.get_term_link($term).'">'.$term->name.'</a>';
} ?>

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)