domain: use camelCase instead of snake_case
authorisaacs <i@izs.me>
Wed, 26 Dec 2012 20:31:27 +0000 (12:31 -0800)
committerisaacs <i@izs.me>
Sat, 29 Dec 2012 18:37:31 +0000 (10:37 -0800)
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.

doc/api/domain.markdown
lib/domain.js
lib/events.js
src/node.js
test/simple/test-domain-implicit-fs.js
test/simple/test-domain.js

index 24acd29..4161e25 100644 (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
index 32259d7..7af08eb 100644 (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);
index eb0aa16..223015e 100644 (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;
       }
index bfd312b..98523c5 100644 (file)
           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.
index 665a821..c701c93 100644 (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');
index 183e2de..c47e2d7 100644 (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;
   }