UNPKG

1.89 kBMarkdownView Raw
1# Axios Exceptions
2
3> A package wrapping the Exceptions class to use axios. Using avLogMessagesApi to log errors.
4
5[![Version](https://img.shields.io/npm/v/@availity/exceptions-axios.svg?style=for-the-badge)](https://www.npmjs.com/package/@availity/exceptions-axios)
6
7More details about configuration can be found in [Exceptions-Core](../exceptions-core)
8
9## Install
10
11### NPM
12
13```bash
14$ npm install @availity/exceptions-axios
15```
16
17### Yarn
18
19```bash
20$ yarn add @availity/exceptions-axios
21```
22
23add module to your app.
24
25```js
26import avExceptionsAxios from '@availity/exceptions-axios';
27```
28
29To configure the default Options
30
31```js
32import avExceptionsAxios from '@availity/exceptions-axios';
33
34avExceptionsAxios.enabled(false); // enabled defaults to true... this example would disable it
35avExceptionsAxios.appId('exampleApp'); // if undefined, logs 'N/A'
36avExceptionsAxios.repeatTime(5000); // sets the time in ms between logging calls for the same error message. (default 5 seconds)
37});
38```
39
40It will automatically catch all error which bubble up to the window (error which are not caught and handled in code) and log those errors. So as long as you are not catching your error you should be able to throw and error to log it.
41
42```js
43// this import doesn't need to be on every file, just needs to be imported once somewhere like the main index.js or App.js
44import avExceptionsAxios from '@availity/exceptions-axios';
45
46//... somewhere when something happened
47throw new Error('As long as this error is not caught it will be logged');
48});
49```
50
51Or you can manually log and error in the case where something is catching and handling errors before they bubble to the window:
52
53```js
54import avExceptionsAxios from '@availity/exceptions-axios';
55
56//... somewhere when something happened
57avExceptionsAxios.submitError(new Error('Manually logging this error'));
58});
59```
60
61## License
62
63[MIT](../../LICENSE)