You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Catching and Reporting Application-wide Uncaught Errors
68
68
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.*
70
70
71
71
```js
72
72
var errors =require('@google-cloud/error-reporting')();
// Report that same error the Stackdriver Error Service
77
77
errors.report(e);
78
78
});
79
+
80
+
process.on('unhandledRejection', (reason, p) => {
81
+
errors.report('Unhandled rejection of promise: '+ p +', reason: '+ reason);
82
+
});
79
83
```
80
84
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).
0 commit comments