How Do I Debug My Application?
Caja's runtime library writes errors and diagnostics
with console.log(), so it's probably
easier to work in a browser that supports console.log(), such as
Firefox+Firebug, Safari 4, or IE 8.
First, if you're getting weird error messages, check if they're explained here.
Most LINT and WARNING messages
are harmless and can be ignored. However, there's one
WARNING that's important:
WARNING: failed to load external url ...
The reason that's important: External scripts are not
currently supported, but Caja doesn't flag that as a fatal
error. If you see that warning for
a <script> tag, then your
application probably won't work. Fix that problem
first. Either inline the external script, or modify your code
to eliminate the external dependency.
alert() works, but the messages are
redirected to Firebug's console.
Always check your JavaScript console for messages, even if you aren't getting JavaScript errors. Sometimes Caja's runtime will print an error message without throwing or re-throwing an exception, so tools like Firebug will not notice it's an error and will not notify you.
YML Alters Caja Line Numbers
The line numbers in Caja's error messages are line numbers that Caja sees, which is not necessarily the same as the line numbers in your source code. In particular, YML transformation happens before Caja, so if you use any YML tags, the line numbers reported by Caja might be offset by an arbitrary amount.
At the moment, there isn't an easy way to determine the original line number.
For compile-time errors, Caja will print the source line text for each error, and hopefully that's enough to identify the actual location.
For run-time errors, you can sometimes figure out the real location by looking at the JavaScript that Caja generates.

