Permalink
Browse files

clean up

  • Loading branch information...
1 parent ec238b7 commit 42d22b0516c98c6eaf7165ccfa0dda6efa49ea91 Gabriel Llamas committed Dec 1, 2013
Showing with 16 additions and 26 deletions.
  1. +0 −7 lib/error.js
  2. +3 −5 lib/parse.js
  3. +13 −14 lib/read.js
View
@@ -1,7 +0,0 @@
-"use strict";
-
-module.exports = function (msg){
- var error = new Error (msg);
- error.name = "PropertiesError";
- return error;
-};
View
@@ -1,7 +1,5 @@
"use strict";
-var PropertiesError = require ("./error");
-
//The data doesn't need to be buffered because .properties files typically
//have a size less than a block (default is 16KB)
@@ -254,7 +252,7 @@ module.exports = function (data, options, handlers, control){
isSectionLine = false;
if (!ignoreLine){
//The section doesn't end with ], it's a key
- control.error = PropertiesError ("The section line \"" + section +
+ control.error = new Error ("The section line \"" + section +
"\" must end with \"]\"");
return;
}
@@ -273,8 +271,8 @@ module.exports = function (data, options, handlers, control){
if (isSectionLine && !ignoreLine){
//The section doesn't end with ], it's a key
- control.error = PropertiesError ("The section line \"" + section + "\" " +
- "must end with \"]\"");
+ control.error = new Error ("The section line \"" + section + "\" must end" +
+ "with \"]\"");
return;
}
line ();
View
@@ -3,7 +3,6 @@
var fs = require ("fs");
var path = require ("path");
var parse = require ("./parse");
-var PropertiesError = require ("./error");
var INCLUDE_KEY = "include";
var INDEX_FILE = "index.properties";
@@ -50,8 +49,8 @@ var expand = function (o, str, options, cb){
}else if (c === "}"){
holder = section !== null ? o[section] : o;
if (!holder){
- return cb (PropertiesError ("The section \"" + section +
- "\" does not exist"));
+ return cb (new Error ("The section \"" + section + "\" does not " +
+ "exist"));
}
v = holder[key];
@@ -64,8 +63,8 @@ var expand = function (o, str, options, cb){
}
if (v === undefined){
- return cb (PropertiesError ("The property \"" + key +
- "\" does not exist"));
+ return cb (new Error ("The property \"" + key + "\" does not " +
+ "exist"));
}
}
@@ -81,7 +80,7 @@ var expand = function (o, str, options, cb){
}
if (stack.length !== 0){
- return cb (PropertiesError ("Malformed variable: " + str));
+ return cb (new Error ("Malformed variable: " + str));
}
cb (null, key);
@@ -147,8 +146,8 @@ var build = function (data, options, dirname, cb){
var include = function (value){
if (currentSection !== null){
- return abort (PropertiesError ("Cannot include files from inside " +
- "a section: " + currentSection));
+ return abort (new Error ("Cannot include files from inside a " +
+ "section: " + currentSection));
}
var p = path.resolve (dirname, value);
@@ -388,8 +387,8 @@ module.exports = function (data, options, cb){
comments.forEach (function (comment){
code = comment.charCodeAt (0);
if (comment.length > 1 || code < 33 || code > 126){
- throw PropertiesError ("The comment token must be a single printable " +
- "ASCII character");
+ throw new Error ("The comment token must be a single printable ASCII " +
+ "character");
}
c[comment] = true;
});
@@ -401,16 +400,16 @@ module.exports = function (data, options, cb){
separators.forEach (function (separator){
code = separator.charCodeAt (0);
if (separator.length > 1 || code < 33 || code > 126){
- throw PropertiesError ("The separator token must be a single printable " +
- "ASCII character");
+ throw new Error ("The separator token must be a single printable ASCII " +
+ "character");
}
s[separator] = true;
});
options._separators = s;
if (options.path){
- if (!cb) throw PropertiesError ("A callback must be passed if the data " +
- "is a path");
+ if (!cb) throw new Error ("A callback must be passed if the data is a " +
+ "path");
if (options.include){
read (data, options, cb);
}else{

0 comments on commit 42d22b0

Please sign in to comment.