File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
src/connections/sources/catalog/libraries/server/node Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -350,6 +350,30 @@ var analytics = new Analytics('YOUR_WRITE_KEY', {
350350 </tr >
351351</table >
352352
353+ ### Error Handling
354+
355+ Additionally there is an optional ` errorHandler ` property available to the class constructor's options.
356+ If unspecified, the behaviour of the library does not change.
357+ If specified, when an axios request fails, ` errorHandler(axiosError) ` will be called instead of re-throwing the axios error.
358+
359+ Example usage:
360+ ``` javascript
361+ const Analytics = require (' analytics-node' );
362+
363+ const client = new Analytics (' write key' , {
364+ errorHandler : (err ) => {
365+ console .error (' analytics-node flush failed.' )
366+ console .error (err)
367+ }
368+ });
369+
370+ client .track ({
371+ event : ' event name' ,
372+ userId: ' user id'
373+ });
374+
375+ ```
376+ If this fails when flushed no exception will be thrown, instead the axios error will be logged to the console.
353377
354378## Development
355379
You can’t perform that action at this time.
0 commit comments