/** * * * <pre> * The location in the source code where the decision was made to * report the error, usually the place where it was logged. * For a logged exception this would be the source line where the * exception is logged, usually close to the place where it was * caught. This value is in contrast to `Exception.cause_location`, * which describes the source line where the exception was thrown. * </pre> * * <code>.google.devtools.clouderrorreporting.v1beta1.SourceLocation report_location = 3;</code> */ public Builder setReportLocation( com.google.devtools.clouderrorreporting.v1beta1.SourceLocation.Builder builderForValue) { if (reportLocationBuilder_ == null) { reportLocation_ = builderForValue.build(); onChanged(); } else { reportLocationBuilder_.setMessage(builderForValue.build()); } return this; } /**
/** * * * <pre> * The location in the source code where the decision was made to * report the error, usually the place where it was logged. * For a logged exception this would be the source line where the * exception is logged, usually close to the place where it was * caught. This value is in contrast to `Exception.cause_location`, * which describes the source line where the exception was thrown. * </pre> * * <code>.google.devtools.clouderrorreporting.v1beta1.SourceLocation report_location = 3;</code> */ public Builder setReportLocation( com.google.devtools.clouderrorreporting.v1beta1.SourceLocation.Builder builderForValue) { if (reportLocationBuilder_ == null) { reportLocation_ = builderForValue.build(); onChanged(); } else { reportLocationBuilder_.setMessage(builderForValue.build()); } return this; } /**
public static void executeNoCatch(String projectId) throws Exception { try (ReportErrorsServiceClient client = ReportErrorsServiceClient.create()) { ProjectName projectName = ProjectName.of(projectId); String message = "[MESSAGE]"; String service = "[SERVICE]"; ServiceContext serviceContext = ServiceContext.newBuilder().setService(service).build(); String filePath = "path/to/file.lang"; int lineNumber = 42; String functionName = "meaningOfLife"; SourceLocation reportLocation = SourceLocation.newBuilder() .setFilePath(filePath) .setLineNumber(lineNumber) .setFunctionName(functionName) .build(); ErrorContext context = ErrorContext.newBuilder().setReportLocation(reportLocation).build(); ReportedErrorEvent event = ReportedErrorEvent.newBuilder() .setMessage(message) .setServiceContext(serviceContext) .setContext(context) .build(); ReportErrorEventResponse response = client.reportErrorEvent(projectName, event); } }