0.1.4 • Published 10 years ago
pokemon-master v0.1.4
You have errors in your application? pokemon-master will catch'em all!
Tiny, flexible CoffeeScript module
Examples
Handler = require 'pokemon-master'
handle = new Handler()
# Defining specific handler
handle.bind('ReferenceError', (err) ->
console.log 'Something wrong with called function'
)
try
# Calling unknown function foo
foo()
catch err
# Forwarding error to handler
handle.forward(err, 'ReferenceError')
You can also define a default handlers:
Handler = require 'pokemon-master'
handle = new Handler()
handle.on('default', (err) ->
console.log err.stack
)
try
foo()
catch err
handle.forward(err)
API
Handler.on(errorName, callback)
Define function(callback
) that will be called when errorName
occurs
Handler.forward(error, errorName)
Forward occured error by defined callback, if no callback defined for errorName
Handler will throw error
Develop
git clone https://github.com/G07cha/pokemon-master.git
npm install
npm test
You also can use default gulp task for continuous CoffeeScript compiling
License
MIT © Konstantin Azizov