WP_Error with get_category_parents

If you call get_the_category() without a parameter you have to use it in a loop – after the_post(); was called. Otherwise get_the_category() returns FALSE and get_category_parents() returns a WP_Error object … which is lacking a toString() method and therefore cannot be printed.

So test if you get an object or a string before you try to echo the return value.