Skip to content

Commit

Permalink
domain: use camelCase instead of snake_case
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
isaacs committed Dec 29, 2012
1 parent 4401bb4 commit ec8ebaf
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 32 deletions.
6 changes: 3 additions & 3 deletions doc/api/domain.markdown
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/domain.js
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions lib/events.js
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/node.js
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions test/simple/test-domain-implicit-fs.js
Expand Up @@ -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');
Expand Down
44 changes: 22 additions & 22 deletions test/simple/test-domain.js
Expand Up @@ -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');
Expand All @@ -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;
}

Expand Down

0 comments on commit ec8ebaf

Please sign in to comment.