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 @@ -352,6 +352,30 @@ var analytics = new Analytics('YOUR_WRITE_KEY', {
352352 </tr >
353353</table >
354354
355+ ### Error Handling
356+
357+ Additionally there is an optional ` errorHandler ` property available to the class constructor's options.
358+ If unspecified, the behaviour of the library does not change.
359+ If specified, when an axios request fails, ` errorHandler(axiosError) ` will be called instead of re-throwing the axios error.
360+
361+ Example usage:
362+ ``` javascript
363+ const Analytics = require (' analytics-node' );
364+
365+ const client = new Analytics (' write key' , {
366+ errorHandler : (err ) => {
367+ console .error (' analytics-node flush failed.' )
368+ console .error (err)
369+ }
370+ });
371+
372+ client .track ({
373+ event : ' event name' ,
374+ userId: ' user id'
375+ });
376+
377+ ```
378+ If this fails when flushed no exception will be thrown, instead the axios error will be logged to the console.
355379
356380## Development
357381
You can’t perform that action at this time.
0 commit comments