owl
owl copied to clipboard
have better error messages
As an example, I'm currently having this error in my console, and except the first line which gives me a hint, it doesn't help at all because all of the traceback lines are inside owl.
What I want to see is where on my code there is a crash: either a JS line number, or some hint about which template and potentially where on this template it happens.
TypeError: "context.storeProps.computed is undefined" owl.js:3678:17
anonymous http://127.0.0.1:8069/web/static/lib/owl/owl.js line 1572 > Function:15
fn http://127.0.0.1:8069/web/static/lib/owl/owl.js:1450
render http://127.0.0.1:8069/web/static/lib/owl/owl.js:1499
render http://127.0.0.1:8069/web/static/lib/owl/owl.js:3881
__render http://127.0.0.1:8069/web/static/lib/owl/owl.js:3552
__prepareAndRender http://127.0.0.1:8069/web/static/lib/owl/owl.js:3542
errorHandler http://127.0.0.1:8069/web/static/lib/owl/owl.js:3678
__render http://127.0.0.1:8069/web/static/lib/owl/owl.js:3560
__prepareAndRender http://127.0.0.1:8069/web/static/lib/owl/owl.js:3542
Another problematic error:
Uncaught (in promise) TypeError: Cannot read property 'length' of undefined
at QWeb.eval (eval at _compile (owl.js:1567), <anonymous>:50:72)
at QWeb.fn (owl.js:1445)
at QWeb.render (owl.js:1494)
at Object.__owl__.renderFn (owl.js:4086)
at MessageList.__render (owl.js:3773)
at MessageList.__prepareAndRender (owl.js:3763)
This error is a little bit better out of the box because it tells on the render of which component it happened. But of course the problematic line on the template would be better here too.
fun fact: i think that your second error is a little bit better because it was obtained in Chrome, and your first error comes from firefox...
This is actually quite annoying, it is difficult to work with different browsers. There are no good way to introspect an error, so we have to try to parse the message string or the stack.
Different browsers indeed.
well, after working on this for a time, I can say that handling/introspecting errors in JS is really really really bad.
- firefox has a
lineNumber
attribute, other browsers don't - we need to parse the stack, which is not standardized, to extract a line number
- chrome and firefox dev tools are confused when breaking on errors that occur in a compiled piece of code: one of them display the breakpoint 2 lines higher than it should, the other 2 lines lower...
- modifying name/message properties of an error kind of work, except that firefox does not display the updated property in the console. Oh, and Chrome does not display the updated name/property if we are in a debugger/dev tools open, but it does use them in the console if the dev tools are closed...
- nodejs has still different numbers, and it is not compatible with the other
All of that together, I really do not see how I can provide a decent error in all cases... So, i will stop working on this for now, unless someone has an idea...
This is probably a terrible idea, but maybe keep variables names when generating variables in compiled code to help dev finding the issue
maybe also add (in dev mode) a comment of the xml line we are processing