/**
 * Creates a JS Error object from an NSException pointer.
 */
var id = require('./id')
  , Err = require('vm').runInNewContext('Error')

var proto = exports.proto = Err.prototype
// Make the Error objects inherit from our id class
proto.__proto__ = id.proto

exports.wrap = function wrap (pointer) {
  var w = id.wrap(pointer)
  w.__proto__ = proto
  w.name = String(w('name'))
  w.message = String(w('reason'))
  Err.captureStackTrace(w, exports.wrap)
  return w
}

/**
 * Creates a JS Error object from an NSException pointer.
 */
var id = require('./id')
  , Err = require('vm').runInNewContext('Error')

var proto = exports.proto = Err.prototype
// Make the Error objects inherit from our id class
proto.__proto__ = id.proto

exports.wrap = function wrap (pointer) {
  var w = id.wrap(pointer)
  w.__proto__ = proto
  // We have to do a little workaround to get a nice 'stack' property, since
  // the 'name' property on the id wraps is non-configurable
  var stacker = new Error(String(w('reason')))
  stacker.name = String(w('name'))
  Err.captureStackTrace(stacker, exports.wrap)
  Object.defineProperty(w, 'stack', Object.getOwnPropertyDescriptor(stacker, 'stack'))
  return w
}

Put in place a little workaround to get a nice 'name' on the NSException wrap's 'stack' property.
Put in place a little workaround to get a nice 'name' on the NSException wrap's 'stack' property.
