Important: The code for this module has been moved into the main Feathers repository at feathersjs/feathers (package direct link). Please open issues and pull requests there. No changes in your existing Feathers applications are necessary.
Common error types for feathers apps
npm install @feathersjs/errors --save
Quick usage:
consterrors=require('@feathersjs/errors');// If you were to create an error yourself.constnotFound=newerrors.NotFound('User does not exist');// You can wrap existing errorsconstexisting=newerrors.GeneralError(newError('I exist'));// You can also pass additional dataconstdata=newerrors.BadRequest('Invalid email',{email: 'sergey@google.com'});// You can also pass additional data without a messageconstdataWithoutMessage=newerrors.BadRequest({email: 'sergey@google.com'});// If you need to pass multiple errorsconstvalidationErrors=newerrors.BadRequest('Invalid Parameters',{errors: {email: 'Email already taken'}});// You can also omit the error message and we'll put in a default one for youconstvalidationErrors=newerrors.BadRequest({errors: {email: 'Invalid Email'}});Please refer to the @feathersjs/errors API documentation for more details.
Copyright (c) 2018 Feathers Contributors
Licensed under the MIT license.
