Skip to content

Commit 00d7971

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

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

functions/helloworld/main.py

Lines 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]
Lines 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
Lines 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)