I have a common function to display errors as a result of an AJAX call. Some of those messages are HTML strings, which I want to convert to a DOM object then search for elements inside it using .find(). Others will be just strings (not HTML). In this case, I don't know how to handle this...it is generating exceptions.

```
var messageTest = "" + this;
if ($(messageTest).length == 0) {
    message += this;
} else {
    message += $(messageTest).find('.message-error').html();
}

```

FYI, "this" in this case seems to be a String object with an array in which each item is a character, so in the inspector, it isn't showing "my message here" but:

```
[0]: "m"
[1]: "y"

```

etc

When it is just a string, which is not HTML, I get an error at the if statement line:

```
Uncaught Error: Syntax error, unrecognized expression:<The contents of messageText>

```

So how to I gracefully handle this when the input could be an HTML string or just a string?

Note...in the end, I just want the string, as I am going to wrap it in it's own HTML.