Package Exports
- feathers-errors
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 (feathers-errors) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
feathers-errors 
Error handling mixin for Feathers apps.
Getting Started
Install the module with: npm install feathers-errors --save
var feathers = require('feathers');
var errors = require('feathers-errors');
var memory = require('feathers-memory');
var app = feathers().configure(errors())
.use('/users', memory('users'))
.use(errors.handler);Documentation
Current Error Types:
GeneralError: 500BadRequest: 400NotAuthenticated: 401Forbidden: 403NotFound: 404Timeout: 409Conflict: 409PaymentError: 409Unprocessable: 422
Pro Tip: Feathers service adapters (ie. mongodb, memory, etc.) already emit the appropriate errors for you. :-)
Usage:
var feathers = require('feathers');
var errors = require('feathers-errors');
var app = feathers();
var userService = {
find: function(params, callback) {
// If you were to create an error yourself.
callback(new this.app.errors.NotFound('User does not exist'));
// You can also simply do something like this if you
// just want to fire back a simple 500 error with your
// custom message.
//
// callback('A generic server error');
},
setup: function(app){
this.app = app;
}
};
app.configure(errors())
.use('/users', userService)
.use(errors.handler);404 Handling:
We have conveniently created a basic 404 middleware as well. To use it:
var feathers = require('feathers');
var errors = require('feathers-errors');
var app = feathers();
app.configure(errors())
.use('/users', userService)
.use(errors.missing) // your 404 handler
.use(errors.handler);Examples
See examples directory.
Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
Release History
0.1.1
- Exposing error types directly via `var types = require('feathers-errors').types;
0.1.0
- Initial release
License
Copyright (c) 2014 Eric Kryski Licensed under the MIT license.