[Groonga-commit] groonga/gcs [master] Throw an error object instead of multiplexed error object

Back to archive index

YUKI Hiroshi null+****@clear*****
Mon Nov 5 14:52:58 JST 2012


YUKI Hiroshi	2012-11-05 14:52:58 +0900 (Mon, 05 Nov 2012)

  New Revision: d4085658785ae183b53a60a7e1d1d39af6c373ff
  https://github.com/groonga/gcs/commit/d4085658785ae183b53a60a7e1d1d39af6c373ff

  Log:
    Throw an error object instead of multiplexed error object

  Modified files:
    lib/database/domain.js

  Modified: lib/database/domain.js (+10 -9)
===================================================================
--- lib/database/domain.js    2012-11-05 14:49:34 +0900 (cbca0dc)
+++ lib/database/domain.js    2012-11-05 14:52:58 +0900 (31cf023)
@@ -51,8 +51,8 @@ function assertValidDomainName(domain) {
                      'to satisfy constraint: ';
 
   if (!domain.match(exports.VALID_NAME_PATTERN)) {
-    errors.push(new Error(commonPrefix + 'Member must satisfy regular ' +
-                          'expression pattern: ' + exports.VALID_NAME_PATTERN));
+    errors.push(commonPrefix + 'Member must satisfy regular ' +
+                'expression pattern: ' + exports.VALID_NAME_PATTERN);
   } else {
     var invalidCharacters = domain.match(exports.INVALID_TABLE_NAME_CHARACTER_PATTERN);
     if (invalidCharacters) {
@@ -60,21 +60,22 @@ function assertValidDomainName(domain) {
                             .map(function(aCharacter) {
                               return "'" + aCharacter + "'";
                             });
-      errors.push(new Error(commonPrefix + 'Member cannot include these ' +
-                            'characters: ' + invalidCharacters.join(', ')));
+      errors.push(commonPrefix + 'Member cannot include these ' +
+                  'characters: ' + invalidCharacters.join(', '));
     }
   }
 
   if (domain.length < exports.MINIMUM_NAME_LENGTH)
-    errors.push(new Error(commonPrefix + 'Member must have length greater ' +
-                          'than or equal to ' + exports.MINIMUM_NAME_LENGTH));
+    errors.push(commonPrefix + 'Member must have length greater ' +
+                'than or equal to ' + exports.MINIMUM_NAME_LENGTH);
 
   if (domain.length > exports.MAXIMUM_NAME_LENGTH)
-    errors.push(new Error(commonPrefix + 'Member must have length smaller ' +
-                          'than or equal to ' + exports.MAXIMUM_NAME_LENGTH));
+    errors.push(commonPrefix + 'Member must have length smaller ' +
+                'than or equal to ' + exports.MAXIMUM_NAME_LENGTH);
 
   if (errors.length)
-    throw errors;
+    throw new Error(errors.length + ' validation errors detected: ' +
+                    errors.join('; '));
 }
 
 
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index