How to use the @feathersjs/errors.Unprocessable 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
// Omit query information
    const messages = error.message.split('-');
    error.message = messages[messages.length - 1];

    switch (error.code.slice(0, 2)) {
      case '22':
      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 feathersjs-ecosystem / feathers-objection / src / error-handler.js View on Github external
break;

      case 406:
        feathersError = new errors.NotAcceptable(error);
        break;

      case 408:
        feathersError = new errors.Timeout(error);
        break;

      case 409:
        feathersError = new errors.Conflict(error);
        break;

      case 422:
        feathersError = new errors.Unprocessable(error);
        break;

      case 501:
        feathersError = new errors.NotImplemented(error);
        break;

      case 503:
        feathersError = new errors.Unavailable(error);
        break;

      case 500:
      default:
        feathersError = new errors.GeneralError(error);
    }

    if (error.data) {