CRAN status


This is an R wrapper for the Google Cloud Platform Error Reporting API. It uses the Error Reporting API as defined in the method.


You can install the development version of googleErrorReportingR from GitHub with:

# install.packages("devtools")


Before you start, please set up a file called .Renviron that contains the following line.

PROJECT_ID=<your gcp project id>

If you are running a session, then restart your R session so that the environmental variables are read.

You can pass on the project_id and api_key to the function call directely, but since we typically use this many time in one code-base we default to the values in the environmental variables so that instead of:

report_error(project_id, api_key, message)

We can call


and put the effort in defining the error message at each location in the code that we want to monitor.

the following is a basic example of usage:


message <- format_error_message()

message$serviceContext$service <- "A demo service"
message$serviceContext$version <- "v0.3.4"

#> Response []
#>   Date: 2022-08-21 01:57
#>   Status: 200
#>   Content-Type: application/json; charset=UTF-8
#>   Size: 3 B
#> {}

If your project-id and api_key are set up correctly the message above will appear in the Google Error Reporting UI as follows:

Screenshot of the message as listed in the Google Error Reporting UI

Adding details

Note that the message we are sending, once we convert the list to the json body as required by the API, contains all the information elements that we can add to the message.

toJSON(message, auto_unbox = TRUE, pretty = TRUE )
#> {
#>   "message": "Error description",
#>   "serviceContext": {
#>     "service": "A demo service",
#>     "version": "v0.3.4"
#>   },
#>   "context": {
#>     "httpRequest": {
#>       "method": "GET",
#>       "url": "",
#>       "userAgent": "",
#>       "referrer": "",
#>       "responseStatusCode": "500",
#>       "remoteIp": ""
#>     },
#>     "user": "UserID",
#>     "reportLocation": {
#>       "filePath": "/",
#>       "lineNumber": 0,
#>       "functionName": "my_function"
#>     }
#>   }
#> }

Please read the vignette for further details on how to configure each and everyone of them.


We are working on the next version of googleErrorReportingR to include the use of the list endpoint.