Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: Exception propagation from C# to Javascript

$
0
0
Hi,

I tried err.hostException, but this came as null.

I then added HostFunctions as host object and tried your next suggestion. But looks like HostFunctions does not have tryCatch().
My Clearscript version is : 5.3.10.0

I tried Like below:
-------adding HostFunctions to engine----------
engine.AddHostObject("host", new HostFunctions());

In javascript

var succeeded = host.tryCatch(
    function() {
        loginResponse = httpclient.Post(url,payload);
    },
    function(exception) {
        hostException = exception;
        return true;
    }
);
if (succeeded) {    
    Log.Info('SUCCESS');
}
else {
    Log.Error('err msg...' + hostException.Message);
    Log.Error('err type...' + hostException.GetBaseException().ToString());
}

This fails saying "Microsoft.ClearScript.ScriptEngineException: TypeError: Object #<HostObject> has no method 'tryCatch'"

Is it what you were suggesting ?

Viewing all articles
Browse latest Browse all 2297

Latest Images

Trending Articles





Latest Images