views:

39

answers:

2

Hi,

i'm doing some unit tests in Silverlight. Therefore i'm invoking some javascript functions. i'd like to know how to get the message of the exception thrown in javascript. Is this possible?

Thanks! Peter

A: 

Here you go:

try {

foo();

} catch (e) {

alert("An exception occurred in the script. Error name: " + e.name 
+ ". Error message: " + e.message); }

<Edit> Sorry, I just realized you need this in C# code. In order to do that, you'll have to take this data and pass it into your C# code somehow, whether by AJAX or form submission or something.

Jaxidian
A: 

Check out Exception Handling Behavior in HTML Bridge from MSDN

Justin Niessner
So I even can't get the message?"If the browser supplies text for the exception message, the text is returned as the exception message. Exception text differs across browsers and may not be available to the HTML Bridge."
Peter Pan