Ok,

I have traced the problem due to the way I was throwing my exceptions.

In JS, I did something like
if (this === that) throw 'thats not good';

When I should have done this
if (this === that) throw new Error('thats not good');

I was not aware of this technique,

For other people's reference, here is a great page about it:
http://www.devthought.com/2011/12/22/a-string-is-not-an-error/

and a v8 wiki page on it:
http://code.google.com/p/v8/wiki/JavaScriptStackTraceApi

thanks again Yang for your responses, I appreciate it.
Paul



On 10 December 2012 23:09, Paul Harris <[email protected]> wrote:

> I'll have to make a more complete example, because I am doing more than
> just putting all that code in one JS script.
>
> I have the factory in a separate script, which I Compile() and Run(),
> The Run() returns the factory function,
> which I then Exec() with parameters.  The result is the { read_something }
> object,
> which I then attach to the global object.
>
> Only then do I compile and run the code that uses the generated wrapper.
>
> On 10 December 2012 18:14, Yang Guo <[email protected]> wrote:
>
>> Not sure what you mean, for this following code:
>>
>> function factory(a) {
>>    return {
>>       read_something: function(i) { if (i < 0) this.die(); return a; }
>>    };
>> };
>>
>>
>> factory(2).read_something(-1);
>>
>> I get:
>>
>> test2.js:3: TypeError: Object #<Object> has no method 'die'
>>       read_something: function(i) { if (i < 0) this.die(); return a; }
>>                                                     ^
>> TypeError: Object #<Object> has no method 'die'
>>     at Object.read_something (test2.js:3:53)
>>     at test2.js:8:12
>>
>>
>> which seems perfectly fine to me.
>>
>> Yang
>>
>>
>> On Thursday, November 29, 2012 4:18:48 PM UTC+1, Paul Harris wrote:
>>>
>>> Hi,
>>>
>>> I have a small bit of code that looks something like this:
>>> (function (a, b, c) {
>>>    return {
>>>       read_something: function(i) { if (i < 0) this.die(); return a; }
>>>    };
>>> });
>>>
>>> I then do something like this:
>>> comp = Script::Compile(code);
>>> wrapper = comp->Run();
>>> binder = wrapper->Call( global, 3, args );
>>> global->Set( ident, binder );
>>>
>>> which compiles, runs (to get the factory-function), then calls the
>>> factory-function with arguments,
>>> resulting in the {} object with read_something function inside.
>>> I then bind this to the global object.
>>> I use this to give me access to data, but at the same time ensure the
>>> data is read-only.
>>>
>>> This works well.  If I call binder.read_something(-1) within javascript,
>>> it correctly dies when trying to call this.die().
>>>
>>> However, the callstack that is printed out only shows the details for
>>> the code within the wrapper,
>>> it does not print out the callstack up to the calling code (which is
>>> compiled and run later).
>>>
>>> Any ideas why this might be?  I am hoping to (eg) find the place where
>>> the calling script calls with a -1 parameter.
>>>
>>> thanks,
>>> Paul
>>>
>>>  --
>> v8-users mailing list
>> [email protected]
>> http://groups.google.com/group/v8-users
>>
>
>

-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users

Reply via email to