I'm using Bryntum chartsand extjs4 for my project.
This is the error I am getting since yesterday
I understand that the method addCls is not defined.
How to tackle this error.
My code file is very big somewhere around 1500 lines, But if it is required for the understanding of question then i will paste the whole code too....
Any help will be appreciated.
put a breakpoint on the line that throws an exception. Figure out which object (culprit) is trying to call addCls() method and then edit the breakpoint to add a condition like this:
culprit == undefined
next time code will halt just before you hit your bug. you can then inspect the stack and see the call hierarchy to this point.
Related
Uncaught (in promise) SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
This error occurs in Firefox console when loading 3rd party Javascript. But Firefox console gives absolutely no information as to whereabouts in the JS this issue occurs. The 3rd Party JS has a host of different JSON parts to it.
I am not familiar enough with JS to dig in and mess around with the code toooo much or spend hours fragmenting it and taking it apart and putting it back together again.
NOTE
There are a lot of questions with identical titles, and each of these show very specific issues with very specific responses. My question is not really about wanting to find the issue in this case (although that would be great).
My Question
How should I (any anyone else) approach trying to find where this error is;
How do we find what data is causing this error?
How do we find which line of JS causes this error?
Reading the MDN (etc) on JSON errors It seems to be easy to resolve once it's been found, but the case is I am having troubles finding how to go abouts digging out where in the JS this issue occurs and/or which data is causing the JSON error.
UPDATE
Further to comments, here is the Debug flow output from Firefox; I'm a little lost in here but this still doesn't seemt to show me what is actually going on.
Some clear pointers that came up in the comments below the question:
Use the Debugger Firefox Inspector tab before refreshing the page and reloading the error.
Somewhat unexpectedly, when on the Debugger tab, the same console error (at the bottom of my screenshot) this time shows a file reference and line number reference and can be clicked on to show a cascade of details.
As mentioned by evolutionxbox and Barmar the Debugger tab should also be showing the variable that's used in the call to JSON.parse.
Using the Debugger Breakpoints tickboxes was very useful for establishing what part of what code was running when the error was encountered.
More will be added here
I am running a Tampermonkey script on a website that I do not have the code for.
Sometimes it happens that I have a value that does not exist on the page and I get the following error:
"Cannot read property 'click' of null"
And the entire script stops. How can I tell get my script to ignore the error and just carry on to the next line of code?
Here is an example of a vanilla Javascript line that I work with:
document.querySelector('[value="xyz"]').click();
Only execute click() if the selector found something:
if(document.querySelector('[value="xyz"]'))
document.querySelector('[value="xyz"]').click();
You can't, and you shouldn't want to: errors are bad. They're not informative, they are a signal that the code has run into an unrecoverable error and the current code path should be terminated. If you were to ignore it, and keep running, now you're in a state where any subsequent line is just as likely to also throw an error.
Either actually fix things, by making your tampermonkey script not interfere with the way the page it's running on builds its DOM, or as a last resort, you can find out which function is throwing the error for the specific page(s) you're running into this, and then _specifically for those pages, find and rebind the entire function using a try/catch, such as:
const _old_fn = window.theFunctionInvolved;
window.theFunctionInvolved = function(...args) {
try { return _old_fn(...args); }
catch (e) {}
};
But of course, all you've now done is moved the buck: you'll have effectively guaranteed different errors later on, with the actual cause now permanently hidden.
So really: don't do this. Fix your tampermonkey script, or stop using it altogether.
So I'm getting the following error:
Uncaught Error: Assertion Failed: The key provided to get must be a string, you passed undefined
Should be easy enough to fix, if there was any indication of the line in my code that causes that error.
Using the chrome console, I click on ember.debug.js:6254 next to the error, which just shows me the ember code that throws the error. I can expand the error, but I just get a bunch of functions that can't be clicked on and no indication where they come from.
Can someone please help me figure out how to identify the line in my Ember code that is causing the error.
I've gotten this error before. It happens when you call get() in any of its forms (Ember.get() or this.get() or get(this)) without a string as the name of the property you want to retrieve.
You should be able to find the source of the error by auditing your application for wherever you call get() and making sure you pass the property name as a string. E.g., Ember.get('model.someProp') or this.get('someProp') or get(this, 'someProp').
This should be a comment but I can't, so here goes:
Iam new to Ember and have been spending quite a long time debugging. Remember that long stack of function calls that chrome's console shows.
Look for anything other than ember.debug.js...especially those marked (anonymous function) and files with names vendor.js or app-name.js
Usually in software development when debugging your best friends are going to be console.log() or alert() (in the case of JavaScript). Usually you have to figure out if your getting what ever is that you passing to your function by consolelog everything until you find your bug. Ember sometimes will not tell you what is exactly the error because does not know where exactly is coming from.
...computers are annoying but we love them....
here are some articles from Mozilla developer and Google on how to debug JavaScript.
I had a NULL value in my database which I wasn't accounting for in my app. In my case, it shouldn't have been NULL in the first place, so after giving the record a value in my database the problem disappeared.
I agree the error message is not very helpful.
Our company site has a JavaScript problem that I'm desperately trying to solve, but really struggling with. My JS skills are good enough to build a site with things like jQuery, but I am not that proficient in debugging - so really appreciate any help.
Seemingly randomly, all JS components (e.g. a jQuery Datepicker) on the page stop working. When force-reloading the page with the error console open, these errors happen about 60% of the time - there doesn't seem to be any pattern to it. The only way to fix the site once this happens is by clearing the cache and reloading.
The Console outputs the following:
Uncaught TypeError: Object #<Object> has no method 'each'
Uncaught TypeError: Object #<Object> has no method 'not'
Uncaught TypeError: Object #<Object> has no method 'each'
However: that's just one example. Other times I will get completely different errors. E.g. a few minutes after submitting this question, I tried again, and got this:
Uncaught TypeError: Cannot call method 'apply' of undefined
Which again was thrown from jquery.min.js - pretty-printed, line 1453 (third line down):
if (g.call(k) === "[object Array]")
if (!u)
e.push.apply(e, k);
I set Chrome to break on all unhandled exceptions, and this was another exception it caught - on line 3 of the minified jQuery library. Shown below is the pretty-printed version:
try {
b.call(c.documentElement, "[test!='']:sizzle")
} catch (f) {
e = !0
}
The actual erroring line begins b.call[...]. This works out to line 1904 of jquery.min.js.
I am using the latest jQuery
This only started happening recently - after changing nothing!
The errors happen seemingly randomly
Usually (but sometimes), no errors are thrown from my scripts - e.g. script.js - usually they are thrown from a minified library. It varies each time.
This seems to happen in all browsers, but more often in Chrome than Firefox
Any ideas where to begin? Unfortunately this is an internal corporate website so providing access is tricky, as we deal with sensitive data throughout the site.
Thank you for your help!
Seems to me that your page is quite big and the browser tries to execute the js code before the DOM loads completely... probably because you're using in-line javascript code..
That could explain the random errors and the fact that you have errors when you force the reload.
I'd suggest you to put your JS code inside a dom ready event so the js code could be executed without problems..
Hope this helps :)
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.
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?
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>
local function ensureAnimDict(animDict)
if not HasAnimDictLoaded(animDict) then
RequestAnimDict(animDict)
while not HasAnimDictLoaded(animDict) do
Wait(0)
end
return animDict
end