Get Error Complex object error after check isStruct or isSimpleValue
<p>I have a code to display message if upload process fails. The message variable can be a struct or a string. I've added code to check if the result is a struct or a simple value but I still get Complex object error. Is there anything that I missed?</p>

<p>Here is my code:</p>

<pre><code>if (isStruct(result)) {
    if(StructKeyExists(result, 'messages')){
        theMessage = result.messages;
    }
}else{
    if(IsSimpleValue(result)){
        theMessage = result;
    }
}
FormMessage=getLang('CVLizerUploadFailed') &amp; ' ' &amp; getLang('PleaseContactYourAdmin') &amp; ', ' &amp; getLang('ErrorCode') &amp; ' ' &amp; theMessage;
</code></pre>