Wrox Programmer Forums
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 6th, 2005, 11:21 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 139
Thanks: 0
Thanked 0 Times in 0 Posts
Default catching error

Hi,

I'm attemtping to catch, and ignore javascript errors... It works for certain messages, but others still get through. Could anyone help me out with this? I'm pulling data, and putting it to an Excel sheet, and Excel is very fragile which is why I want to ignore and continue... The one error message that seems to always get through is "Call was rejected by callee."

window.onerror = handleErrors
function handleErrors(msg, url, line)
{
    createLog(msg,line);
    return (true);
}

function createLog(msg,line)
{
    var fs = new ActiveXObject("Scripting.FileSystemObject");
    var path = getPath();
    path += "\\logs\\" + timeStamp() + ".txt";

    if (!fs.FileExists(path))
        var a = fs.CreateTextFile(path, true);
    else
        var a = fs.OpenTextFile(path, 8, false);

    for (i=0;i<appRunningArr.length;i++)
        if (appRunningArr[i] == true)
        {
            runningApp += listAppArr[i] + " ";
            restartApp(listAppArr[i]);
        }

    a.WriteLine("Error occured at: " + getTime());
    a.WriteLine("Message: " + msg);
    a.WriteLine("Line: " + line);
    a.WriteLine("Running application(s): " + runningApp);
    a.WriteLine("");
}

 
Old December 8th, 2005, 03:10 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 344
Thanks: 0
Thanked 1 Time in 1 Post
Default

This looks like you are using Javascript on the server side, is that correct ? you may want to look at http://www.greggriffiths.org/webdev/both/excel/ which covers some client and server side approaches to populating Excel via the web.
 
Old December 9th, 2005, 05:09 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

The error seems to be arising through a breakdown between the COM server and IE, this will not be caught by window.onerror but might be caught by a try/catch block. What is the relevant Excel automation code?

--

Joe (Microsoft MVP - XML)
 
Old December 13th, 2005, 03:14 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 139
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This is all on the client Side... sadly I have no server helping out on this...

How would I go about to do a try/catch???

 
Old December 14th, 2005, 01:44 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Code:
try
{
  //Your Excel code here
}
catch(e)
{
  alert(e.message); //Take appropriate action
}
--

Joe (Microsoft MVP - XML)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Catching a SQLException error digriz60 ASP.NET 1.0 and 1.1 Basics 5 January 14th, 2008 03:14 PM
Catching Up John Kauffman BOOK: Beginning ASP.NET 2.0 and Databases 2 October 2nd, 2006 05:04 PM
Error catching and throwing - code rjp Access VBA 1 August 25th, 2004 08:32 PM
catching error fyeojo VS.NET 2002/2003 4 August 13th, 2003 08:29 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.