Skip to content

Commit d8d24a1

Browse files
committed
errors-report:Document unhandledRejection handling
1 parent 925e651 commit d8d24a1

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

packages/error-reporting/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ errors.report(new Error('Something broke!'));
6666

6767
## Catching and Reporting Application-wide Uncaught Errors
6868

69-
*It is recommended to catch `uncaughtExceptions` for production-deployed applications.*
69+
Uncaught exceptions and unhandled rejections are not reported by default. *It is recommended to process `uncaughtException`s and `unhandledRejection`s for production-deployed applications.*
7070

7171
```js
7272
var errors = require('@google-cloud/error-reporting')();
@@ -76,9 +76,13 @@ process.on('uncaughtException', (e) => {
7676
// Report that same error the Stackdriver Error Service
7777
errors.report(e);
7878
});
79+
80+
process.on('unhandledRejection', (reason, p) => {
81+
errors.report('Unhandled rejection of promise: ' + p + ', reason: ' + reason);
82+
});
7983
```
8084

81-
More information about uncaught exception handling in Node.js and what it means for your application can be found [here](https://nodejs.org/api/process.html#process_event_uncaughtexception).
85+
More information on uncaught exception handling in Node.js can be found [here](https://nodejs.org/api/process.html#process_event_uncaughtexception), and more information on unhandled promise handling can be found [here](https://nodejs.org/api/process.html#process_event_unhandledrejection).
8286

8387
## Running on Google Cloud Platform
8488

0 commit comments

Comments
 (0)