Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear sir,

How to get Error Line number and line text using Javascript

please anybody known tell me how?

Thanks in advance.
Posted
Comments
Graham Breach 27-Mar-12 5:44am    
If you mean Javascript errors, you should look in the Javascript console (or Error console in Firefox, Developer tools in IE).

I can give you just the idea.

You can do it from analysis of the value of the member .stack of the exception object:

C#
function ProcessExceptionInformation(message, stack) {
    // extract position information from stack
    // output or log the exception information as required
}

//...

<pre lang="JavaScript">try {
    //do something
} catch(e) {
    ProcessExceptionInformation(e.message, e.stack);
}


—SA
 
Share this answer
 
hi,
To check where error occurs you can use tool, like firebug(with firefox)to debug javascript
for IE with latest browser you can use developer tool by pressing F12
 
Share this answer
 
Comments
Mohankumar.Engain 27-Mar-12 6:41am    
I need, if error occur in my page automatically display/send me error line

so that's y i need
Sergey Alexandrovich Kryukov 27-Mar-12 20:04pm    
I think I know how it works; please see my answer.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900