Skip to content

Commit 0c983b5

Browse files
authored
Merge branch 'main' into create-doc
2 parents db3a2ec + 7aba33f commit 0c983b5

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

error-reporting/quickstart.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,25 @@
1414

1515
'use strict';
1616

17+
// [START error_reporting_quickstart]
18+
// Import the Google Cloud client library
19+
const {ErrorReporting} = require('@google-cloud/error-reporting');
20+
1721
function quickstart() {
18-
// [START error_reporting_quickstart]
19-
// Imports the Google Cloud client library
20-
const {ErrorReporting} = require('@google-cloud/error-reporting');
22+
try {
23+
throw new Error('Something went wrong');
24+
} catch (exception) {
25+
reportError(exception);
26+
}
27+
}
2128

29+
function reportError(exception) {
2230
// Instantiates a client
2331
const errors = new ErrorReporting();
2432

25-
// Reports a simple error
26-
errors.report('Something broke!');
27-
// [END error_reporting_quickstart]
33+
// Reports an exception
34+
errors.report(exception.stack);
2835
}
36+
// [END error_reporting_quickstart]
37+
2938
quickstart();

0 commit comments

Comments
 (0)