Skip to content
This repository has been archived by the owner on Mar 24, 2023. It is now read-only.
/ cauliflower Public archive

A simple error handler library

License

Notifications You must be signed in to change notification settings

alkemics/cauliflower

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cauliflower

A simple error handler library

Build Status

Installation

npm install --save cauliflower

Simple use case

var cauliflower = require('cauliflower');

cauliflower.on('Error.api.networkUnavailable', function (name, e) {
  console.log('Error ' + e.message);
});

And elsewhere

var cauliflower = require('cauliflower');
var error = { message: 'Network is unavaiable' };
cauliflower.throw('Error.api.networkUnavailable', error);

Pattern

var cauliflower = require('cauliflower');

cauliflower.on(/^Error/, function (name, e) {
  console.log('Error ' + e.message);
});

var error = { message: 'Permission denied' };
cauliflower.throw('Error.permission', error);

Handlers

var cauliflower = require('cauliflower');

var myHandler = {
  name: 'myUberHandler',
  catch: function (name, e) {
    console.log('Error ' + name + ' catched: ' + e);
  }
};

cauliflower.addHandler(myHandler);

cauliflower.on(/^Error/, 'myUberHandler');

var error = { message: 'Permission denied' };
cauliflower.throw('Error.permission', error);

About

A simple error handler library

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •