Report runtime function errors (1st gen)
You should handle and report runtime errors that occur in Cloud Run functions. Uncaught exceptions or executions that crash the process can result in cold starts, which you should generally try to minimize.
The recommended way for a function to signal an error depends on the function type:
HTTP functions should return appropriate HTTP status codes which denote an error. See HTTP Functions for more information.
Event-driven functions should log and return an error message. See Write event-driven functions for more information.
If errors are appropriately handled, then function instances that encounter errors can remain active and available to serve requests.
Emit errors to Error Reporting
You can emit an error from a Cloud Run function to Error Reporting as shown in the following:
Node.js
Python
Go
Java
If you would like more fine-grained error reporting, you can use the Error Reporting client libraries.
You can view the reported errors in Error Reporting in the Google Cloud console. You can also see the errors reported from a particular function when you select it from the list of functions in the Google Cloud console.
Uncaught exceptions produced by your function will appear in Error Reporting. Note that some types of uncaught exceptions (such as those thrown asynchronously) will cause a cold start to occur upon a future function invocation. This increases the amount of time your function will take to run.