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 618d19c

Browse filesBrowse files
committed
Add error reporting sample for manual reporting
1 parent eb22abb commit 618d19c
Copy full SHA for 618d19c

File tree

Expand file treeCollapse file tree

2 files changed

+17
-8
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+17
-8
lines changed

‎error_reporting/report_exception.py

Copy file name to clipboardExpand all lines: error_reporting/report_exception.py
+13-3Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
# [START error_reporting]
16-
from google.cloud import error_reporting
17-
1815

16+
# [START error_reporting]
1917
def simulate_error():
18+
from google.cloud import error_reporting
19+
2020
client = error_reporting.Client()
2121
try:
2222
# simulate calling a method that's not defined
@@ -26,5 +26,15 @@ def simulate_error():
2626
# [END error_reporting]
2727

2828

29+
# [START error_reporting_manual]
30+
def report_manual_error():
31+
from google.cloud import error_reporting
32+
33+
client = error_reporting.Client()
34+
client.report("An error has occurred.")
35+
# [END error_reporting_manual]
36+
37+
2938
if __name__ == '__main__':
3039
simulate_error()
40+
report_manual_error()

‎error_reporting/report_exception_test.py

Copy file name to clipboardExpand all lines: error_reporting/report_exception_test.py
+4-5Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,12 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import pytest
16-
1715
import report_exception
1816

1917

20-
@pytest.mark.xfail(
21-
strict=True,
22-
reason='GoogleCloudPlatform/google-cloud-python#3263')
2318
def test_error_sends():
2419
report_exception.simulate_error()
20+
21+
22+
def test_manual_error_sends():
23+
report_exception.report_manual_error()

0 commit comments

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