1. feathers-errors
Common error types for feathers apps
feathers-errors
Package: feathers-errors
Created by: feathersjs
Last modified: Fri, 17 Jun 2022 23:58:16 GMT
Version: 2.9.2
License: MIT
Downloads: 18,178
Repository: https://github.com/feathersjs/feathers-errors

Install

npm install feathers-errors
yarn add feathers-errors

feathers-errors

Greenkeeper badge

Build Status
Code Climate
Test Coverage
Dependency Status
Download Status
Slack Status

Common error types for feathers apps

Getting Started

Feathers errors come with feathers by default. So typically you don't need to install it at all.

In the event that you do need to install it:

 npm install --save feathers-errors

Documentation

Current Error Types:

  • BadRequest: 400
  • NotAuthenticated: 401
  • PaymentError: 402
  • Forbidden: 403
  • NotFound: 404
  • MethodNotAllowed: 405
  • NotAcceptable: 406
  • Timeout: 408
  • Conflict: 409
  • LengthRequired: 411
  • Unprocessable: 422
  • TooManyRequests: 429
  • GeneralError: 500
  • NotImplemented: 501
  • BadGateway: 502
  • Unavailable: 503

Pro Tip: Feathers service adapters (ie. mongodb, memory, etc.) already emit the appropriate errors for you. :-)

Usage:

 import errors from 'feathers-errors';

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

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

// You can also pass additional data
var data = new errors.BadRequest('Invalid email', {email: '[email protected]'});

// You can also pass additional data
var dataWithoutMessage = new errors.BadRequest({email: '[email protected]'});

// If you need to pass multiple errors
var 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
var validationErrors = new errors.BadRequest({errors: {email: 'Invalid Email'} });

License

Copyright (c) 2016 Feathers Contributors

Licensed under the MIT license.

Dependencies

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code