Hello!
ClearScript 5.4 does include a generalized version of
Please let us know if handling host exceptions this way isn't practical in your scenario. Unlike the older script engines, V8 could probably enable a more natural pattern, although ClearScript currently doesn't support that.
Thanks!
ClearScript 5.4 does include a generalized version of
tryCatch()
. Here's an example:engine.AddHostObject("host", new HostFunctions()); engine.AddHostType("Console", typeof(Console)); engine.AddHostType("WebClient", typeof(WebClient)); engine.Execute(@" var webClient = new WebClient(); host.tryCatch( function () { // download web document Console.WriteLine(webClient.DownloadString('http://cnn.com')); }, function (exception) { // dump exception Console.WriteLine('*** ERROR: ' + exception.GetBaseException().ToString()); return true; }, function () { // clean up Console.WriteLine('*** CLEANING UP ***'); webClient.Dispose(); } ); ");
Thanks!