Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a7d63b3

Browse filesBrowse files
author
Ace Nassri
authored
Add try-except example to error reporting (GoogleCloudPlatform#1659)
* Update main.py * Add Stackdriver error reporting instructions Change-Id: I8fe091456bad352936d43a7174059c7b3a35721f * Include error reporting in requirements.txt Change-Id: I3bace7962c92440d6ac3ac0169ef5ad52e06072b * Fix typo Change-Id: I42113c49d165d0b04b2ff401b236b3347913c8c8
1 parent fb7bdb5 commit a7d63b3
Copy full SHA for a7d63b3

File tree

Expand file treeCollapse file tree

2 files changed

+12
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+12
-0
lines changed

‎functions/helloworld/main.py

Copy file name to clipboardExpand all lines: functions/helloworld/main.py
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,17 @@ def hello_method(request):
149149

150150
def hello_error_1(request):
151151
# [START functions_helloworld_error]
152+
# This WILL be reported to Stackdriver Error
153+
# Reporting, and WILL NOT show up in logs or
154+
# terminate the function.
155+
from google.cloud import error_reporting
156+
client = error_reporting.Client()
157+
158+
try:
159+
raise RuntimeError('I failed you')
160+
except RuntimeError:
161+
client.report_exception()
162+
152163
# This WILL be reported to Stackdriver Error Reporting,
153164
# and WILL terminate the function
154165
raise RuntimeError('I failed you')

‎functions/helloworld/requirements.txt

Copy file name to clipboard
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
google-cloud-error-reporting==0.30.0

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.