Use is_wp_error() function to check if it's a wp error object instead of get_class()

get_class() function takes an object as argument while on query success the return type is either int or string, so is_wp_error(), an do the same irrespective of return type.