javascript how to find an error in a script
-
03-12-2019 - |
Question
I know this is a little to less to get an answer on what the problem is so what I ask is how to debug it.
I get the following error (the image below). No line, script or anything specified. Also except the ones in jQuery and raphaeljs libraries I don't have any custom error handler defined.
Got any ideas on how to debug this?
(The main script for example has around 3k lines and since I don't know where the error occurs I don't know witch part of it to post. I need only a way to find that.)
Thank you for your time.
Solution
This happens when the script throws a string, rather than a proper exception, like:
throw 'Error in protected function: )55';
See this other SO question for possible solutions:
How can I get a Javascript stack trace when I throw an exception?
OTHER TIPS
Try chrome. Webkit can provide stack traces: Web Inspector: Understanding Stack Traces
Sample:
<script>
function i2(){
throw "CustomError";
}
function invoke(){
i2();
}
</script>
<button onclick="invoke()">yo</button>