MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / manual

Function manual

error-reporting/manual.js:22–52  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

20'use strict';
21
22function 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}
53manual();

Callers 1

manual.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected