Skip to content

Commit

Permalink
Add some description around error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomohito Nakayama committed Feb 22, 2016
1 parent 9f4bedf commit cfc7715
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Processor of json file
## module
var jf = require('json.filed')

## functions
## executers
### filed
````
jf.filed( file )
Expand Down Expand Up @@ -90,5 +90,36 @@ jf.filed( file )

io,copy and link and filter and pass can be chained as above.

## Error handling
### Error listener of executer
Error captured in each executer can be handled in error listener of executer
````
jf.filed(
file,
function( err ) { your code to handle error here } )
.io(
function( j, f ) { ... },
function( err ) { your code to handle error here } )
````

Each executer is emitter and you can send error to them.
````
.pass(
function( j, f, executer) {
executer.emit('error', {msg: "some of error" } )
},
function( err ) { your code to handle error here } )
````

### DefaultEmitter
Error captured not in each executer can be handled in error listener of defaultEmitter
````
var jf = require( '../../' )
jf.defaultEmitter.removeAllListeners( 'error' );
jf.defaultEmitter.on(
'error',
function( err ){ your code to handle error here }
);
````

## binary format (bson) support

0 comments on commit cfc7715

Please sign in to comment.