@ihadeed/errors
TypeScript icon, indicating that this package has built-in type declarations

600.0.0 • Public • Published

@feathersjs/errors

Build Status Dependency Status Download Status

Common error types for feathers apps

Installation

npm install @feathersjs/errors --save

Quick usage:

const errors = require('@feathersjs/errors');

// If you were to create an error yourself.
const notFound = new errors.NotFound('User does not exist');

// You can wrap existing errors
const existing = new errors.GeneralError(new Error('I exist'));

// You can also pass additional data
const data = new errors.BadRequest('Invalid email', {
  email: 'sergey@google.com'
});

// You can also pass additional data without a message
const dataWithoutMessage = new errors.BadRequest({
  email: 'sergey@google.com'
});

// If you need to pass multiple errors
const validationErrors = new errors.BadRequest('Invalid Parameters', {
  errors: { email: 'Email already taken' }
});

// You can also omit the error message and we'll put in a default one for you
const validationErrors = new errors.BadRequest({
  errors: {
    email: 'Invalid Email'
  }
});

Documentation

Please refer to the @feathersjs/errors API documentation for more details.

License

Copyright (c) 2018 Feathers Contributors

Licensed under the MIT license.

Package Sidebar

Install

npm i @ihadeed/errors

Weekly Downloads

3

Version

600.0.0

License

MIT

Unpacked Size

38.5 kB

Total Files

6

Last publish

Collaborators

  • ihadeed