| 20 | 'use strict'; |
| 21 | |
| 22 | function manual() { |
| 23 | // [START error_reporting_setup_nodejs_manual] |
| 24 | // Imports the Google Cloud client library |
| 25 | const {ErrorReporting} = require('@google-cloud/error-reporting'); |
| 26 | |
| 27 | // Instantiates a client |
| 28 | const errors = new ErrorReporting(); |
| 29 | |
| 30 | // Use the error message builder to customize all fields ... |
| 31 | const errorEvent = errors.event(); |
| 32 | |
| 33 | // Add error information |
| 34 | errorEvent.setMessage('My error message'); |
| 35 | errorEvent.setUser('root@nexus'); |
| 36 | |
| 37 | // Report the error event |
| 38 | errors.report(errorEvent, () => { |
| 39 | console.log('Done reporting error event!'); |
| 40 | }); |
| 41 | |
| 42 | // Report an Error object |
| 43 | errors.report(new Error('My error message'), () => { |
| 44 | console.log('Done reporting Error object!'); |
| 45 | }); |
| 46 | |
| 47 | // Report an error by provided just a string |
| 48 | errors.report('My error message', () => { |
| 49 | console.log('Done reporting error string!'); |
| 50 | }); |
| 51 | // [END error_reporting_setup_nodejs_manual] |
| 52 | } |
| 53 | manual(); |