Catch and Show an error from a WCF service call in javascript.
        Posted  
        
            by cw
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by cw
        
        
        
        Published on 2010-04-28T15:36:12Z
        Indexed on 
            2010/04/28
            18:37 UTC
        
        
        Read the original article
        Hit count: 325
        
wcf
|JavaScript
Hello,
I'm calling a WCF service through javascript and right now it's not showing any errors that might occur on the service side to the user. I have the code below and am looking for a better way to inform the user an error has occured, including the call stack and error message if possible.
The service itself throws a FaultException if an error has occured. However, I want to catch that error in the javascript call and show it to the user.
Here is the js code to call the service
function Save() {
    var saveInfo = $("._saveInfo").val()
    app.namspace.interfacetoservice.Save(
        saveInfo,
        function(results) {
            if (results == true) {
                window.close();
            }
            else {
                alert("error saving");
            }
        }
    );
}
Thanks for the help!
© Stack Overflow or respective owner