Subj : Re: Catch-all method To : Harry Ohlsen From : Brendan Eich Date : Wed Jul 30 2003 11:15 pm Harry Ohlsen wrote: > I'm not sure whether this is something that's in the standard > definition of Javascript, but it would be helpful to me if there was a > way to catch attempts to call functions that don't exist. Does Rhino > have such a mechanism? > > By the way, I realise that I can put the call in a try/catch block, > but that's not of use to me, because I'm looking for a generic way to > handle this, in code written by end-users (and I don't want them to > have to know this is happening). > > What I want to do is catch the call, so I can check whether there is a > function in an external repository of scripts. If so, I would load it > dynamically and re-execute the call. > > Hence, it would be important that the code that catches the problem is > passed the list of parameters from the original, failed call. > > In Ruby this is handled by having a method called method_missing. I > believe, in Smalltalk, it's called no_such_method. See http://bugzilla.mozilla.org/show_bug.cgi?id=213482 for the request to add such a method to SpiderMonkey. I don't believe there's an equivalent bug for Rhino. /be .