On Jun 19, 10:36 am, Mike Tardif <[EMAIL PROTECTED]> wrote:
> On Jun 18, 8:28 pm, Norris Boyd <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Jun 18, 4:57 pm, Mike Tardif <[EMAIL PROTECTED]> wrote:
>
> > > Hi Again
>
> > > I've exposed my objects (whose properties are dynamic) to JavaScript
> > > by deriving from ScriptableObject and generally all is good.
>
> > > But I've failed to properly deal with this JavaScript scenario:
> > >     try {
> > >          myObject.notMyProperty = "hello"
> > >     }
> > >     catch(e) {
> > >           "unrecognized property"
> > >     }
> > >     "hello world"
>
> > > My question is: in myObject's put(String, Scriptable, Object) method,
> > > what kind of RhinoException do I throw when myObject recognizes that
> > > notMyProperty is invalid, so that catch block in the above script gets
> > > executed as well as any code that follows.
>
> > > I wish the docs for Scriptable and/or ScriptableObject would expand  a
> > > bit more on exception handling.
>
> > Standard JavaScript behavior is that assignment to an undefined
> > property results in creation of the property. That means that I didn't
> > define a standard exception for failures. What kind of failure are you
> > wanting to throw an exception for?
>
> > --Norris
>
> Thanks for the quick reply.  I should have added that I'm trying to
> emulate this script behaviour
> that is running on two other JS engines.  The designer of "myObj"
> spec'ed it out to throw on undefined
> properties.  Is there any way to trick Rhino into throwing?
> Scriptable.has() apparently gets called before a put (the docs say a
> set).  Maybe that's the approach I should take.

That's fine, Java objects behave this way when accessed from
JavaScript. Probably the easiest thing to do is to throw a
WrappedException constructed with a Java exception type that you
define.

--N
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to