Package Exports
- herro
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (herro) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
herro!
What if stack traces looked like this?
| changes... | adds... |
|---|---|
node_modules/moduleName to moduleName@version |
an arch badge with format node@version |
project-path to project-path@version |
a source being the first node_module encountered |
Note: If package.json doesn't exist project-path will be relative to the outer directory of your PWD.
install
npm install herro --saveusage
The package gives two flavors. One declarative and other imperative.
imperative: make it so
To enforce any v8 stacktrace to have the package names.
Options:
| NODE_ENV = test | herro#everywhere |
flood flag |
|---|---|---|
Stack traces are "humanized" for the test environment by default. |
var herro = require('herro').everywhere() |
export ERROR_FLOOD=true |
declarative: customize error instances
var herro = require('herro');
herro.set('my-custom-error', function(err){
err.message = error.message + ' with orange juice please';
return err;
});
var myErrorClass = herror.get('my-custom-error');
throw new myErrorClass('Excuse me dear, I would fancy coffee and toasts');
// or also
throw new herror.get('my-custom-error', 'Excuse me dear, I would fancy coffee and toasts')which as you would guess will throw
throw new myErrorClass('Excuse me dear, I would fancy coffee and toasts')
^
Error: Excuse me dear, I would fancy coffee and toasts with orange juice please
source: herro@0.0.16/lib/herro.js:103:19
--
> new errorClass (herro@0.0.16/lib/herro.js:103:19)
at Object.<anonymous> (herro@0.0.16/test/test.Herror.set.js:47:7)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
--
node@0.10.30api
herro.Herror
Inherits from Error. An error class with formatted stack trace. You can call it with and without new.
Herror.call or apply will expect you to use an Error instance for this.
That is:
var herro = require('herro').Herror;
var myThing = {};
Herror.call(myThing)
Herror.apply(myTHing)
// Both above will failherro.set(name, handle)
Set your error classes here. Chainable method.
name: astringor anobjecthandle: afunction
The first argument passed to the handle is a Herror instance.
If name is a string then handle should be a function. If handle is not given name is expected to be an object.
Sugar for this:
var herro = require('herro');
herro
.set('my-error', function(err){
err.message = ' argument `'+err.message+'` not supported';
return err;
}).set('other error', function(err){
err.message = ' go out and take some beers already!'
return err;
})
// the above is equivalent to
herro.set({
'my-error' : function(err){
err.message = ' argument `'+err.message+'` not supported';
return err;
},
'other error' : function(err){
err.message = ' go out and take some beers already!'
return err;
}
})
All classes inherit from Herror if you want that changed let me know.
herro.get(name[, message])
Get the errorClass you set with herro.set
name: astringmessage: optionalstringmessage.
If message is not given returns your errorClass name.
If message is given returns an error instance of that errorClass name with that message.
flags
Enforce all stack traces to show package versions:
export ERROR_FLOOD=true && node index.jsShut up all the way down
export NO_FLAGS && node index.jsThe above in case anyone left process.env.ERROR_FLOOD = true written somewhere.
tests
make testor
npm testThus far node 0.8 and above are behaving.
todo
- make more tests.
- more interfaces for error instances (like
Herror.streamorHerror.catch) that would be helpful to have.


