repl.load problem

19 views
Skip to first unread message

Ale

unread,
Dec 14, 2011, 12:27:43 PM12/14/11
to MozLab
Hi,
I have some problems with repl.load.
Let's say I have a foo.js files and I load it with repl.load,
and then modify the function bar() defined inside foo.js.
Reloading foo doesn't update the function definition.
Is there a way to change this behavior?

Massimiliano Mirra

unread,
Dec 14, 2011, 12:39:10 PM12/14/11
to moz...@googlegroups.com
Try appending a "?" plus a random number at the end of the file URL you're trying to load, like "....something.js?1234". If it works, then the problem is due to the recent introduction in Firefox of a script cache, and I might work around it in future versions of MozRepl.
M


--
You received this message because you are subscribed to the Google Groups "MozLab" group.
To post to this group, send email to moz...@googlegroups.com.
To unsubscribe from this group, send email to mozlab+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mozlab?hl=en.


Ale

unread,
Dec 14, 2011, 12:59:49 PM12/14/11
to MozLab
Thanks for the prompt answer. Your solution worked perfectly.

By the way, is there any easy way to get a stack trace directly at the
repl when an exception occurs? I know I could write a new interactor
(or modify mozrepl's default interactor) but I don't really know where
should I start, I'm a javascript/mozilla internals newbie :)

Grazie ancora e buon lavoro :)
__
Alessandro

Massimiliano Mirra

unread,
Dec 14, 2011, 5:31:13 PM12/14/11
to moz...@googlegroups.com
If you call a function from the repl and an exception happens somewhere in the call chain, you should get a stack trace directly at the repl. If the exception happens outside of the call chain (e.g. you request data from the network, register a callback to handle that data, then something goes wrong in the callback) the repl can't catch it and therefore can't show it.

Workarounds would be to check in the JavaScript console where the exceptions is happening, wrap the area in a try...catch and then print it to the system console (i.e. the terminal you started Firefox from):

  dump(exceptionObject.stack + '\n')

Or to the JavaScript console:

  Component.utils.reportError(exceptionObject.stack)

It might be possible to direct all JavaScript errors, filtered by source file, to the repl, but I've never looked into that.

Buon lavoro anche a te. :)
M

Ale

unread,
Dec 15, 2011, 4:21:25 AM12/15/11
to MozLab
For some reason I'm not getting the stack trace.
I loaded this file:
----------- cane.js -----------

function crasto(x) {
if (x === 0)
throw(new Error('division by 0!'));
else return 1/x;
}
function bobby() { crasto(0);}
function jimmy() { bobby(); }
-------------------------------------

and at the repl, when calling jimmy(), I get

-------repl output--------
repl> jimmy()
!!! Error: division by 0!

Details:

fileName: chrome://mozrepl/content/repl.js -> file:////home/ale/src/cane.js?0
lineNumber: 3
-------------------------------

For some reason, if I copy paste the javascriptInteractor code from
repl.js in my mozrepl init file and define a new interactor and push
it, I can see the stack trace.

I changed the error reporting code to get a simpler view like this:

---------------------------------------
repl> jimmy()
!!! Error: division by 0!

Trace:
crasto(0) -> file:////home/ale/src/cane.js?0:3
bobby() -> file:////home/ale/src/cane.js?0:8
jimmy() -> file:////home/ale/src/cane.js?0:12
-----------------------------------------

__
Alessandro

Reply all
Reply to author
Forward
0 new messages