UNPKG

@rapharacing/error-handler

Version:

Error Handler

58 lines (39 loc) 2.67 kB
# Rapha Error Handler [![pipeline status](https://gitlab.com/rapharacing/rapha-front-end/error-handler/badges/master/pipeline.svg)](https://gitlab.com/rapharacing/rapha-front-end/error-handler/commits/master) [![coverage report](https://gitlab.com/rapharacing/rapha-front-end/error-handler/badges/master/coverage.svg)](https://gitlab.com/rapharacing/rapha-front-end/error-handler/commits/master) [![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://github.com/facebook/jest) [![MIT License][license-image]][license-url] [license-image]: http://img.shields.io/badge/license-MIT-blue.svg?style=flat [license-url]: https://gitlab.com/rapharacing/rapha-front-end/error-handler/-/blob/master/LICENCE.md Transform and translated error messages for client-side applications and middlware. ## Features - [**Babel**](https://babeljs.io/) - Write next generation JavaScript today. - [**Jest**](https://facebook.github.io/jest) - JavaScript testing framework used by Facebook. - [**ESLint**](http://eslint.org/) - Make sure you are writing a quality code. - [**Prettier**](https://prettier.io/) - Enforces a consistent style by parsing your code and re-printing it. - [**Travis CI**](https://travis-ci.org) - Automate tests and linting for every push or pull request. - [**Documentation**](http://documentation.js.org/) - A documentation system so good, you'll actually write documentation. - [**Standard Version**](https://github.com/conventional-changelog/standard-version) - Automate versioning and CHANGELOG generation. ## API #### Table of Contents - [getError](#getError) - [Parameters](#parameters) ### getError Returns a transformed and translated error message for the FE or MW. These can be further tailored for Customer service by passing an optional param #### Parameters - `error` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Error string - `locale` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Locale string - `cs` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Customer service boolean Returns **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Translated error message string ```js import getError from "@rapharacing/error-handler"; const error = getError("AccessDeniedException", "en"); ``` ## Commands ```sh $ yarn test # run tests with Jest $ yarn coverage # run tests with coverage and open it on browser $ yarn lint # lint code $ yarn docs # generate docs $ yarn build # generate docs and transpile code ```