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

1.0.2 • Public • Published

FFY Errors

Standard errors for FFY

Usage

Install

Install the module on your node server or service via command line ´´´ npm install @operanex/ffy-errors ´´´ Or via yarn ´´´ yarn add @operanex/ffy-errors ´´´

Generate errors

The errors are used to be handled by Express but could be used by other systems, in order to create an error perform the following

import errors from '@operanex/ffy-errors'

const err = errors.notAuthorized(`You do not have access to this API`);

Handle errors in express

import { isFFYError, errors } from '@operanex/ffy-errors'

app.use((error: FFYError|Error, req, res, next) => {
  if(isFFYError(error)) {
    res.status(error.httpCode).json({
      message : error.message,
      code: error.code,
      data: error.data 
    })
  } else {
    res.status(500).json(errors.serverError(error))
  }
})

Development

Process of publishing

  1. Develop
  2. Run your tests npm test or yarn test
  3. Run lint npm run lint or yarn lint if there is an issue you can run npm run lint-fix or yarn lint-fix to fix them.
  4. Upgrade your version by running npm version prepatch
  5. Push your version

Readme

Keywords

none

Package Sidebar

Install

npm i @operanex/ffy-errors

Weekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

22.3 kB

Total Files

20

Last publish

Collaborators

  • yehudiduhey