You can emit an error from a Cloud Function to Cloud Logging Error Reporting as shown below:
Node.js
Python
Go
Java
If you would like more fine-grained error reporting, you can use the Cloud Logging Error Reporting Client Libraries.
You can view the reported errors in Cloud Logging Error Reporting in the Cloud Console. You can also see the errors reported from a particular function when you select it from the list of functions in the Cloud Console.
Uncaught exceptions produced by your function will appear in Cloud Logging 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.