Use is_wp_error() instead of get_class()

get_class() takes an object as an argument, in case of success the returned value is either string or int, not an object which would generate a PHP Warning.
so instead of get class, is_wp_error(), function can be used to check if it's a wp_error