Comparing version 0.1.6 to 0.2.0
17
eraro.js
@@ -31,5 +31,6 @@ /* Copyright (c) 2014 Richard Rodger, MIT License */ | ||
// * _package_ : (optional) String; package name to mark Error objects | ||
// * _prefix_ : (optional) Boolean/String; If false, then no prefix is used; If not defined, the package name is used | ||
// * _module_ : (optional) Object; _module_ object to use as starting point for _require_ calls | ||
// * _msgmap_ : (optional) Object; map codes to message templates | ||
// * _prefix_ : (optional) Boolean/String; If false, then no prefix is used; If not defined, the package name is used | ||
// * _module_ : (optional) Object; _module_ object to use as starting point for _require_ calls | ||
// * _msgmap_ : (optional) Object; map codes to message templates | ||
// * _inspect_ : (optional) Boolean; If true, _util.inspect_ is called on values; default: true. | ||
// | ||
@@ -63,2 +64,3 @@ // Returns: Function | ||
var msgmap = options.msgmap || {} | ||
var inspect = null == options.inspect ? true : !!options.inspect | ||
@@ -84,3 +86,3 @@ var markers = [module.filename] | ||
details = _.isObject(details) ? details : (_.isObject(msg) && !_.isString(msg) ? msg : {}) | ||
msg = buildmessage(msg,msgmap,msgprefix,code,details) | ||
msg = buildmessage(msg,msgmap,msgprefix,inspect,code,details) | ||
@@ -161,3 +163,3 @@ if( !ex ) { | ||
// Returns: String; human readable error message | ||
function buildmessage(msg,msgmap,msgprefix,code,details) { | ||
function buildmessage(msg,msgmap,msgprefix,inspect,code,details) { | ||
var message = msgprefix + (_.isString(msg) ? msg : _.isString(msgmap[code]) ? msgmap[code] : code ) | ||
@@ -176,3 +178,3 @@ | ||
if( {'undefined':1,'NaN':1}[key] ) { key = key+'$' } | ||
valstrmap[key] = val | ||
valstrmap[key] = inspect && !_.isString(val) ? util.inspect(val) : val | ||
}) | ||
@@ -183,3 +185,4 @@ | ||
try { | ||
message = _.template( message, valstrmap ) | ||
var tm = _.template( message ) | ||
message = tm(valstrmap) | ||
done = true | ||
@@ -186,0 +189,0 @@ } |
{ | ||
"name": "eraro", | ||
"version": "0.1.6", | ||
"version": "0.2.0", | ||
"description": "Create JavaScript Error objects with code strings, context details, and templated messages.", | ||
@@ -27,8 +27,8 @@ "main": "eraro.js", | ||
"dependencies": { | ||
"underscore": "~1.6.0" | ||
"underscore": "~1.7.0" | ||
}, | ||
"devDependencies": { | ||
"mocha": "~1.18.2", | ||
"mocha": "~1.20.1", | ||
"docco": "~0.6.3", | ||
"jshint": "~2.5.0" | ||
"jshint": "~2.5.10" | ||
}, | ||
@@ -35,0 +35,0 @@ "files": [ |
@@ -74,3 +74,3 @@ eraro | ||
The _package_ option is normally the name of your library. That is, the value | ||
the _name_ property in _package.json_. The generated Error object will | ||
of the _name_ property in _package.json_. The generated Error object will | ||
have two properties to define the package: _package_, a string that is | ||
@@ -152,3 +152,13 @@ the name of the package, and also a boolean, the name of the package itself. | ||
# Options | ||
When creating an _error_ function, you can use the following options: | ||
* _package_ : (optional) String; package name to mark Error objects | ||
* _prefix_ : (optional) Boolean/String; If false, then no prefix is used; If not defined, the package name is used | ||
* _module_ : (optional) Object; _module_ object to use as starting point for _require_ calls | ||
* _msgmap_ : (optional) Object; map codes to message templates | ||
* _inspect_ : (optional) Boolean; If true, _util.inspect_ is called on values; default: true. | ||
# In the Wild | ||
@@ -165,5 +175,5 @@ | ||
Current Version: 0.1.6 | ||
Current Version: 0.2.0 | ||
Tested on: node 0.10.28, 0.11.13 | ||
Tested on: node 0.10.31 | ||
@@ -173,1 +183,2 @@ [![Build Status](https://travis-ci.org/rjrodger/eraro.png?branch=master)](https://travis-ci.org/rjrodger/eraro) | ||
[Annotated Source](http://rjrodger.github.io/eraro/doc/eraro.html) | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12793
157
181
+ Addedunderscore@1.7.0(transitive)
- Removedunderscore@1.6.0(transitive)
Updatedunderscore@~1.7.0