2929
3030/**
3131 * Snippet demonstrates using the Cloud Error Reporting API to report a custom error event.
32- * <p>
33- * This library is not required on App Engine, errors written to stderr are automatically written
34- * to Cloud Error Reporting.
35- * It is also not required if you are writing logs to Cloud Logging.
36- * Errors written to Cloud Logging that contain an exception or stack trace
37- * are automatically written out to Cloud Error Reporting.
32+ *
33+ * <p>This library is not required on App Engine, errors written to stderr are automatically written
34+ * to Cloud Error Reporting. It is also not required if you are writing logs to Cloud Logging.
35+ * Errors written to Cloud Logging that contain an exception or stack trace are automatically
36+ * written out to Cloud Error Reporting.
3837 */
3938public class QuickStart {
4039 public static void main (String [] args ) throws Exception {
@@ -47,20 +46,23 @@ public static void main(String[] args) throws Exception {
4746 try (ReportErrorsServiceClient reportErrorsServiceClient = ReportErrorsServiceClient .create ()) {
4847
4948 // Custom error events require an error reporting location as well.
50- ErrorContext errorContext = ErrorContext .newBuilder ()
51- .setReportLocation (SourceLocation .newBuilder ()
52- .setFilePath ("Test.java" )
53- .setLineNumber (10 )
54- .setFunctionName ("myMethod" )
55- .build ())
56- .build ();
49+ ErrorContext errorContext =
50+ ErrorContext .newBuilder ()
51+ .setReportLocation (
52+ SourceLocation .newBuilder ()
53+ .setFilePath ("Test.java" )
54+ .setLineNumber (10 )
55+ .setFunctionName ("myMethod" )
56+ .build ())
57+ .build ();
5758
58- //Report a custom error event
59- ReportedErrorEvent customErrorEvent = ReportedErrorEvent .getDefaultInstance ()
60- .toBuilder ()
61- .setMessage ("custom error event" )
62- .setContext (errorContext )
63- .build ();
59+ // Report a custom error event
60+ ReportedErrorEvent customErrorEvent =
61+ ReportedErrorEvent .getDefaultInstance ()
62+ .toBuilder ()
63+ .setMessage ("custom error event" )
64+ .setContext (errorContext )
65+ .build ();
6466 // Report an event synchronously, use .reportErrorEventCallable for asynchronous reporting.
6567 reportErrorsServiceClient .reportErrorEvent (projectName , customErrorEvent );
6668 }
0 commit comments