How to use the @feathersjs/errors.FeathersError function in @feathersjs/errors

To help you get started, we’ve selected a few @feathersjs/errors examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github feathersjs-ecosystem / feathers-knex / lib / error-handler.js View on Github external
case '23':
        feathersError = new errors.BadRequest(message);
        break;
      case '28':
        feathersError = new errors.Forbidden(message);
        break;
      case '3D':
      case '3F':
      case '42':
        feathersError = new errors.Unprocessable(message);
        break;
      default:
        feathersError = new errors.GeneralError(message);
        break;
    }
  } else if (!(error instanceof errors.FeathersError)) {
    feathersError = new errors.GeneralError(message);
  }

  feathersError[ERROR] = error;

  throw feathersError;
};
github jenkins-infra / evergreen / services / src / services / update / update.class.js View on Github external
const FeathersSequelize = require('feathers-sequelize');
const errors            = require('@feathersjs/errors');
const logger            = require('winston');

class NotModified extends errors.FeathersError {
  constructor(message, data) {
    super(message, 'not-modified', 304, 'NotModified', data);
  }
}

/*
 * This class exist mostly as a wrapper around the feathers-sequelize service
 * for the Update model.
 */
class Update extends FeathersSequelize.Service {
  constructor(options) {
    super(options);

    this.app = options.app;

    /*
github feathersjs-ecosystem / feathers-elasticsearch / lib / index.js View on Github external
function errorHandler (error, id) {
  if (error instanceof errors.FeathersError) {
    throw error;
  }

  const statusCode = error.statusCode;

  if (statusCode === 404 && id !== undefined) {
    throw new errors.NotFound(`No record found for id '${id}'`);
  }

  if (errors[statusCode]) {
    throw new errors[statusCode](error.message, error);
  }

  throw new errors.GeneralError(error.message, error);
}