domain: use camelCase instead of snake_case

While it's true that error objects have a history of getting snake_case
properties attached by the host system, it's a point of confusion to
Node users that comes up a lot.  It's still 'experimental', so best to
change this sooner rather than later.
This commit is contained in:
isaacs 2012-12-26 12:31:27 -08:00
parent 4401bb47bf
commit ec8ebaf300
6 changed files with 32 additions and 32 deletions

View File

@ -27,11 +27,11 @@ Any time an Error object is routed through a domain, a few extra fields
are added to it.
* `error.domain` The domain that first handled the error.
* `error.domain_emitter` The event emitter that emitted an 'error' event
* `error.domainEmitter` The event emitter that emitted an 'error' event
with the error object.
* `error.domain_bound` The callback function which was bound to the
* `error.domainBound` The callback function which was bound to the
domain, and passed an error as its first argument.
* `error.domain_thrown` A boolean indicating whether the error was
* `error.domainThrown` A boolean indicating whether the error was
thrown, emitted, or passed to a bound callback function.
## Implicit Binding

View File

@ -140,8 +140,8 @@ Domain.prototype.bind = function(cb, interceptError) {
(arguments[0] instanceof Error)) {
var er = arguments[0];
util._extend(er, {
domain_bound: cb,
domain_thrown: false,
domainBound: cb,
domainThrown: false,
domain: self
});
self.emit('error', er);

View File

@ -58,9 +58,9 @@ EventEmitter.prototype.emit = function(type) {
{
if (this.domain) {
var er = arguments[1];
er.domain_emitter = this;
er.domainEmitter = this;
er.domain = this.domain;
er.domain_thrown = false;
er.domainThrown = false;
this.domain.emit('error', er);
return false;
}

View File

@ -231,7 +231,7 @@
return true;
er.domain = domain;
er.domain_thrown = true;
er.domainThrown = true;
// wrap this in a try/catch so we don't get infinite throwing
try {
// One of three things will happen here.

View File

@ -36,8 +36,8 @@ d.on('error', function(er) {
console.error('caught', er);
assert.strictEqual(er.domain, d);
assert.strictEqual(er.domain_thrown, true);
assert.ok(!er.domain_emitter);
assert.strictEqual(er.domainThrown, true);
assert.ok(!er.domainEmitter);
assert.strictEqual(er.code, 'ENOENT');
assert.ok(/\bthis file does not exist\b/i.test(er.path));
assert.strictEqual(typeof er.errno, 'number');

View File

@ -53,28 +53,28 @@ d.on('error', function(er) {
switch (er_message) {
case 'emitted':
assert.equal(er.domain, d);
assert.equal(er.domain_emitter, e);
assert.equal(er.domain_thrown, false);
assert.equal(er.domainEmitter, e);
assert.equal(er.domainThrown, false);
break;
case 'bound':
assert.ok(!er.domain_emitter);
assert.ok(!er.domainEmitter);
assert.equal(er.domain, d);
assert.equal(er.domain_bound, fn);
assert.equal(er.domain_thrown, false);
assert.equal(er.domainBound, fn);
assert.equal(er.domainThrown, false);
break;
case 'thrown':
assert.ok(!er.domain_emitter);
assert.ok(!er.domainEmitter);
assert.equal(er.domain, d);
assert.equal(er.domain_thrown, true);
assert.equal(er.domainThrown, true);
break;
case "ENOENT, open 'this file does not exist'":
assert.equal(er.domain, d);
assert.equal(er.domain_thrown, false);
assert.equal(typeof er.domain_bound, 'function');
assert.ok(!er.domain_emitter);
assert.equal(er.domainThrown, false);
assert.equal(typeof er.domainBound, 'function');
assert.ok(!er.domainEmitter);
assert.equal(er.code, 'ENOENT');
assert.equal(er_path, 'this file does not exist');
assert.equal(typeof er.errno, 'number');
@ -85,33 +85,33 @@ d.on('error', function(er) {
assert.equal(er.code, 'ENOENT');
assert.equal(er_path, 'stream for nonexistent file');
assert.equal(er.domain, d);
assert.equal(er.domain_emitter, fst);
assert.ok(!er.domain_bound);
assert.equal(er.domain_thrown, false);
assert.equal(er.domainEmitter, fst);
assert.ok(!er.domainBound);
assert.equal(er.domainThrown, false);
break;
case 'implicit':
assert.equal(er.domain_emitter, implicit);
assert.equal(er.domainEmitter, implicit);
assert.equal(er.domain, d);
assert.equal(er.domain_thrown, false);
assert.ok(!er.domain_bound);
assert.equal(er.domainThrown, false);
assert.ok(!er.domainBound);
break;
case 'implicit timer':
assert.equal(er.domain, d);
assert.equal(er.domain_thrown, true);
assert.ok(!er.domain_emitter);
assert.ok(!er.domain_bound);
assert.equal(er.domainThrown, true);
assert.ok(!er.domainEmitter);
assert.ok(!er.domainBound);
break;
case 'Cannot call method \'isDirectory\' of undefined':
assert.equal(er.domain, d);
assert.ok(!er.domain_emitter);
assert.ok(!er.domain_bound);
assert.ok(!er.domainEmitter);
assert.ok(!er.domainBound);
break;
default:
console.error('unexpected error, throwing %j', er.message || er);
console.error('unexpected error, throwing %j', er.message, er);
throw er;
}