Yes, this does indeed work. Add this after the `Error.captureStackTrace()`
call:
Object.defineProperty(this, 'stack', { enumerable: true });
Cheers!
On Thu, Feb 23, 2012 at 11:30 AM, Nathan Rajlich <[email protected]>wrote:
> What happened is that V8 switched over to having the 'stack' property be
> non-enumerable, so JSON.stringify(), Object.keys(), and friends do not see
> these properties now. You might be able to alter the property descriptor
> for 'stack' after the Error.captureStackTrace() call.
>
>
> On Thu, Feb 23, 2012 at 6:56 AM, GN <[email protected]> wrote:
>
>> I've just upgraded node from 0.4.12 to 0.6.11 and noticed that my JSON
>> responses that used to have stack traces no longer include it. Am I
>> possibly missing a parameter that needs to be passed in that will
>> bring this functionality back? Here's an example of what I'm doing:
>>
>> function MyError(msg){
>> this.name = 'MyError';
>> this.message = msg;
>> Error.call(this, msg);
>> Error.captureStackTrace(this, this.constructor);
>> }
>>
>> MyError.prototype.__proto__ = Error.prototype;
>>
>> app.get('/test', function(req, res){
>> res.json(new MyError("Where's my stack?");
>> });
>>
>> In nodejs 0.4.12 used to show : { "name" : "MyError", "message" :
>> "Where's my stack?", "stack" : "<stack trace>"}
>> In nodejs 0.6.11 it now shows : { "name" : "MyError", "message" :
>> "Where's my stack?" }
>>
>> Any insight on this will be greatly appreciated. Thanks!
>>
>> --
>> Job Board: http://jobs.nodejs.org/
>> Posting guidelines:
>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>> You received this message because you are subscribed to the Google
>> Groups "nodejs" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> For more options, visit this group at
>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>
>
>
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en