JavaScript error

D

Danny

Hi All,

Trying to debug my web-pages on the client-side, I've created an AJAX
request function, and surrounding all my JS functions with
try...catch, and in the catch section I send a request to my server to
log the JS error.

I'm encountering an error message that I can't seems to find
documentation on...
I'm logging the e.description, and it says: Failed
Just "Failed" and nothing else...

Anyone knows what this is about?
Any documentation?

Thanks,
Danny
 
M

mckoss

Hi All,

Trying to debug my web-pages on the client-side, I've created an AJAX
request function, and surrounding all my JS functions with
try...catch, and in the catch section I send a request to my server to
log the JS error.

I'm encountering an error message that I can't seems to find
documentation on...
I'm logging the e.description, and it says: Failed
Just "Failed" and nothing else...

Anyone knows what this is about?
Any documentation?

Thanks,
Danny

Are you using Firefox/Firebug on the client. Usually you can narrow
down errors easily using the Firefox debugger.
 
D

Danny

Are you using Firefox/Firebug on the client. Usually you can narrow
down errors easily using the Firefox debugger.- Hide quoted text -

- Show quoted text -

Unfortunetly my web-pages supports only IE users... For now,
anyways...

Have you ever seen this kind of JS error?

Danny
 
D

David Mark

Unfortunetly my web-pages supports only IE users... For now,
anyways...

Have you ever seen this kind of JS error?

No, but post the offending code. And BTW, you can get the line number
with a window.onerror handler. Perhaps you will get a more detailed
description as well.
 
K

kai

Hi All,

Trying to debug my web-pages on the client-side, I've created an AJAX
request function, and surrounding all my JS functions with
try...catch, and in the catch section I send a request to my server to
log the JS error.

I'm encountering an error message that I can't seems to find
documentation on...
I'm logging the e.description, and it says: Failed
Just "Failed" and nothing else...

Anyone knows what this is about?
Any documentation?

Thanks,
Danny

You can use the Microsoft Script Debugger for debugging javascript on
IE. It'll also show you the source code where the failure occurred
much like Firebug does.
 
D

Danny

No, but post the offending code. And BTW, you can get the line number
with a window.onerror handler. Perhaps you will get a more detailed
description as well.- Hide quoted text -

- Show quoted text -

Hi David,

Here is an an example of the offending code:
function initCharct()
{
try
{
var loc = charctLocation.split(",");
var size = charctSize.split(",");
var infoArr = imgInfo.split(",");
with(oCharact.style)
{
top = Math.round(loc[1);
left = Math.round(loc[0]);
width = Math.round(size[0]);
height =Math.round(size[1]);
}
with (oCharctFrame.style)
{
width = Math.round(infoArr[2]);
height = Math.round(infoArr[3]);
}
var prop =
calcProperties(0,0,infoArr[2]*1,infoArr[3]*1,0.05).split(",");
with (oCharctImage.style)
{
width = Math.round(prop[2]);
height = Math.round(prop[3]);
}
oCharctImage.src = picSource;

ScaleObject(oCharctImage.id,false);
ScaleObject(oCharctFrame.id,false);
ScaleObject(oCharact.id,true)
}
catch(e)
{
SendHTTPRequest("RnLayoutText.aspx",
"initCharct()",
e.description);
}
}

Strange behaviour:
1. This is not the only function that sends the "Failed" error.
2. For most of the users these functions works just fine... Only 2%-4%
of the users get these errors.
3. Like most of my users, I cannot reproduce these errors, on my
computers.

I've looked into the window.onerror event, great stuff! But for some
reason, using IE, I get the wrong file at the arguments, when the
error occurs in a .js file, and maybe the wrong line sometimes.

Any ideas?

Thanks,
Danny
 
D

Danny

You can use the Microsoft Script Debugger for debugging javascript on
IE. It'll also show you the source code where the failure occurred
much like Firebug does.- Hide quoted text -

- Show quoted text -

Hi kai,

Yes, I can debug my JS code, and I am debugging my code, but the
problem is that like most of my users, I cannot reproduce these
errors, on my computers.
For some reason, these errors occur only for 2%-4% of my users...

Any ideas?

Thanks,
Danny
 
D

David Mark

[snip]
Here is an an example of the offending code:
function initCharct()
{
try
{
var loc = charctLocation.split(",");
var size = charctSize.split(",");
var infoArr = imgInfo.split(",");
with(oCharact.style)
{
top = Math.round(loc[1);

You have a missing square closing bracket. And how do you know what
the length of the array will be?
left = Math.round(loc[0]);
width = Math.round(size[0]);
height =Math.round(size[1]);

Same issue with the array length.
}
with (oCharctFrame.style)
{
width = Math.round(infoArr[2]);
height = Math.round(infoArr[3]);
}

I've read that you shouldn't use "with" clauses in JS. I've never
used them, so perhaps that is why I have never seen this "Failed"
error.
var prop =
calcProperties(0,0,infoArr[2]*1,infoArr[3]*1,0.05).split(",");
with (oCharctImage.style)
{
width = Math.round(prop[2]);
height = Math.round(prop[3]);
}

Same here.
oCharctImage.src = picSource;

ScaleObject(oCharctImage.id,false);
ScaleObject(oCharctFrame.id,false);
ScaleObject(oCharact.id,true)

What is this function?
}
catch(e)
{
SendHTTPRequest("RnLayoutText.aspx",
"initCharct()",
e.description);
}

}

Strange behaviour:
1. This is not the only function that sends the "Failed" error.
2. For most of the users these functions works just fine... Only 2%-4%
of the users get these errors.
3. Like most of my users, I cannot reproduce these errors, on my
computers.

I've looked into the window.onerror event, great stuff! But for some
reason, using IE, I get the wrong file at the arguments, when the
error occurs in a .js file, and maybe the wrong line sometimes.

I don't know why that would be. I have used it to debug external JS
files. What error description do you get?
 
N

Neil

Hi kai,

Yes, I can debug my JS code, and I am debugging my code, but the
problem is that like most of my users, I cannot reproduce these
errors, on my computers.
For some reason, these errors occur only for 2%-4% of my users...

Any ideas?

Thanks,
Danny

Maybe you should try changing the error logger. Right now you use
e.description and I don't know how that differs from message. Try
using the message,name, and number properties like this:

SendHTTPRequest("RnLayoutText.aspx",
"initCharct()",
e.name + ' : ' + e.number + ' : ' + e.message);

name will tell you what kind of error it is, like SyntaxError for
example.
 
D

Danny

[snip]


Here is an an example of the offending code:
function initCharct()
{
try
{
var loc = charctLocation.split(",");
var size = charctSize.split(",");
var infoArr = imgInfo.split(",");
with(oCharact.style)
{
top = Math.round(loc[1);

You have a missing square closing bracket. And how do you know what
the length of the array will be?

I see, but that's not it, I've just deleted a /**/ clause, after
pasting the code.

The length of the arrays are embeded from the C# code like this:
'20,100' or like this '33,45,121,6', etc.
left = Math.round(loc[0]);
width = Math.round(size[0]);
height =Math.round(size[1]);

Same issue with the array length.
}
with (oCharctFrame.style)
{
width = Math.round(infoArr[2]);
height = Math.round(infoArr[3]);
}

I've read that you shouldn't use "with" clauses in JS. I've never
used them, so perhaps that is why I have never seen this "Failed"
error.

Noted.
But I don't think that's the problem, becoz the same user gets a
"Failed" for other functions that has no "with" clauses.
Worth a try, though, to discard all the "with"s.
var prop =
calcProperties(0,0,infoArr[2]*1,infoArr[3]*1,0.05).split(",");
with (oCharctImage.style)
{
width = Math.round(prop[2]);
height = Math.round(prop[3]);
}

Same here.
oCharctImage.src = picSource;
ScaleObject(oCharctImage.id,false);
ScaleObject(oCharctFrame.id,false);
ScaleObject(oCharact.id,true)

What is this function?

It's a function that scales the objects by a certain ratio, but it has
its own try...catch, and doesn't log an error.
I don't know why that would be. I have used it to debug external JS
files. What error description do you get?- Hide quoted text -

- Show quoted text -

I just used a little test to see how it works:

File "General.js":
------------------------------------------------------
function tellerror(msg, url, linenumber){
alert('Error message= '+msg+'\nURL= '+url+'\nLine Number=
'+linenumber);
return true;
}
window.onerror=tellerror

function init(){
document.write(text);
}
------------------------------------------------------

File "test_error.htm":
------------------------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test Errors</title>

<script language="JavaScript" src="General.js" type="text/
javascript"></script>

</head>
<body onload="init();">
</body>
</html>
 
D

Danny

Maybe you should try changing the error logger. Right now you use
e.description and I don't know how that differs from message. Try
using the message,name, and number properties like this:

When using the debugger on localhost, e.description and e.message
always gives the same value...

And the e.number property always gives strange values like:
-2146823279, -2146823281.
Are these error numbers documented somewhere?

And the e.lineNumber property is always 'undefined'.
When using IE, ofcourse.
SendHTTPRequest("RnLayoutText.aspx",
"initCharct()",
e.name + ' : ' + e.number + ' : ' + e.message);

name will tell you what kind of error it is, like SyntaxError for
example.- Hide quoted text -

- Show quoted text -

Great idea!
Might help. Thanks.
 
T

Thomas 'PointedEars' Lahn

Danny said:
Yes, I can debug my JS code, and I am debugging my code, but the
problem is that like most of my users, I cannot reproduce these
errors, on my computers.
For some reason, these errors occur only for 2%-4% of my users...
Any ideas?
[...]
Maybe you should try changing the error logger. Right now you use
e.description and I don't know how that differs from message. Try
using the message,name, and number properties like this:

When using the debugger on localhost, e.description and e.message
always gives the same value...

Quite normal.
And the e.number property always gives strange values like:
-2146823279, -2146823281.
Are these error numbers documented somewhere?
http://msdn2.microsoft.com/en-us/library/hc53e755.aspx
http://msdn2.microsoft.com/en-us/library/7th8s2xk.aspx

And the e.lineNumber property is always 'undefined'.
When using IE, ofcourse.

http://msdn2.microsoft.com/en-us/library/dww52sbt.aspx


PointedEars
 
D

Danny

Danny said:
Yes, I can debug my JS code, and I am debugging my code, but the
problem is that like most of my users, I cannot reproduce these
errors, on my computers.
For some reason, these errors occur only for 2%-4% of my users...
Any ideas?
[...]
Maybe you should try changing the error logger. Right now you use
e.description and I don't know how that differs from message. Try
using the message,name, and number properties like this:
When using the debugger on localhost, e.description and e.message
always gives the same value...

Quite normal.
And the e.number property always gives strange values like:
-2146823279, -2146823281.
Are these error numbers documented somewhere?
http://msdn2.microsoft.com/en-us/li...dn2.microsoft.com/en-us/library/7th8s2xk.aspx

And the e.lineNumber property is always 'undefined'.
When using IE, ofcourse.

http://msdn2.microsoft.com/en-us/library/dww52sbt.aspx

PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16

Thanks man.

Danny
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,159
Messages
2,570,879
Members
47,414
Latest member
GayleWedel

Latest Threads

Top