PDA

View Full Version : getting helpful error messages?



TheMonolith
4 Mar 2010, 7:20 AM
For the 379th time I spend at least half an hour looking for a simple spelling or paranthesis mistake that could have been resolved within a few seconds had there been a helpful error message.

Last time, which was 5 minutes ago, I got the following error messages:


G is undefined
}else if(!comp.events){ ext-all-debug.js (line 18839)

comp is undefined
}else if(!comp.events){ ext-all-debug.js (line 18839)


comp is undefined
}else if(!comp.events){ ext-all-debug.js (line 18839)


comp is undefined
}else if(!comp.events){ ext-all-debug.js (line 18839


Finally, after going through every line of code and having two co-workers proof-read it,
I discovered the problem: I had spelled "Ext.form.Fieldset" instead of "Ext.form.FieldSet".

Why is Ext JS often unable to provide helpful error messages? Is there an architectural reason for that?

I mean I already use ext-all-debug.js and Firebug. What else could I do?

fay
4 Mar 2010, 7:48 AM
1. Use a decent IDE (http://www.extjs.com/learn/Manual:Resources#IDEs), with ExtJS Code Assist, Syntax Checking, etc.

2. Run your code through www.jslint.com (http://www.jslint.com/). Note, some of the IDEs have this built-in.

3. If using JSON, run it through www.jsonlint.com (http://www.jsonlint.com/). Again, some of the IDEs have this built-int.

4. If using XML, run it through www.xmlvalidation.com (http://www.xmlvalidation.com/).

TheMonolith
5 Mar 2010, 12:23 AM
Thanks for the succinct advice fay.

I'm already using Aptana and have also installed Ext JS support, but just found out that Code Assist was not activated for Ext (even though I thought I had activated it).

I also switched from Mozilla JavaScript Validator to JSLint JavaScript Validator. It helped me solve some formal issues.

The JSONLint page you pointed out to me is not very helpful I'm afraid because it throws errors when you write xtype: "panel" instead of "xtype": "panel".

After all this, I'm still getting some cryptic error messages when I run my Ext JS script...

Animal
5 Mar 2010, 2:43 AM
Well, those aren't really cryptic. They tell you what's happened and where.

TheMonolith
10 Mar 2010, 2:48 AM
Okay, now I get these 6 error messages:


types[config.xtype || defaultType] is not a constructor
}else if(!comp.events){ ext-all-debug.js (line18839)

comp is undefined
}else if(!comp.events){ ext-all-debug.js (line18839)


comp is undefined
}else if(!comp.events){ ext-all-debug.js (line18839)


comp is undefined
}else if(!comp.events){ ext-all-debug.js (line18839)


comp is undefined
}else if(!comp.events){ ext-all-debug.js (line18839)


comp is undefined
}else if(!comp.events){ ext-all-debug.js (line18839)


I have checked each of my 12 project files with JSLint and there is no syntax error. Aptana doesn't find any errors, either.

Animal
10 Mar 2010, 2:54 AM
So. It's calling



new types[config.xtype](blah...);


And it's dropping out with the error that that is not a constructor.

So you break in debug, see what config.xtype IS, and realize that you do not have that class in your page. Either you forgot to add it in, or it is 404.

TheMonolith
10 Mar 2010, 3:15 AM
As usual, your answer is right to the point. I forgot to add the script that contains the class that defines the type.

Thank you!