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 00d7971

Browse filesBrowse files
authored
chore: update HelloWorld error samples (GoogleCloudPlatform#8815)
* chore: update HelloWorld error samples * fix lint
1 parent 55d8bf1 commit 00d7971
Copy full SHA for 00d7971

File tree

Expand file treeCollapse file tree

3 files changed

+11
-11
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+11
-11
lines changed

‎functions/helloworld/main.py

Copy file name to clipboardExpand all lines: functions/helloworld/main.py
+7-7Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import sys
16-
1715
# [START functions_helloworld_http]
1816
# [START functions_http_content]
1917
from flask import escape
@@ -187,8 +185,9 @@ def hello_method(request):
187185
# [END functions_http_method]
188186

189187

188+
# [START functions_helloworld_error]
189+
@functions_framework.http
190190
def hello_error_1(request):
191-
# [START functions_helloworld_error]
192191
# This WILL be reported to Error Reporting,
193192
# and WILL NOT show up in logs or
194193
# terminate the function.
@@ -203,15 +202,16 @@ def hello_error_1(request):
203202
# This WILL be reported to Error Reporting,
204203
# and WILL terminate the function
205204
raise RuntimeError('I failed you')
206-
207-
# [END functions_helloworld_error]
205+
# [END functions_helloworld_error]
208206

209207

208+
# [START functions_helloworld_error]
209+
@functions_framework.http
210210
def hello_error_2(request):
211-
# [START functions_helloworld_error]
212211
# These errors WILL NOT be reported to Error
213212
# Reporting, but will show up in logs.
214213
import logging
214+
import sys
215215
print(RuntimeError('I failed you (print to stdout)'))
216216
logging.warn(RuntimeError('I failed you (logging.warn)'))
217217
logging.error(RuntimeError('I failed you (logging.error)'))
@@ -221,4 +221,4 @@ def hello_error_2(request):
221221
# to Error Reporting, but the status code (500) WILL be logged.
222222
from flask import abort
223223
return abort(500)
224-
# [END functions_helloworld_error]
224+
# [END functions_helloworld_error]
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
functions-framework==3.2.0
2-
mock==4.0.3
3-
pytest==7.0.1
1+
functions-framework==3.2.1
2+
mock==4.0.3
3+
pytest==7.0.1
44
uuid==1.30

‎functions/helloworld/requirements.txt

Copy file name to clipboard
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
functions-framework==3.2.0
1+
functions-framework==3.2.1
22
flask==2.1.0
33
google-cloud-error-reporting==1.6.0

0 commit comments

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