if (class(try(as.character(xx)))=="try-error") {
...
}