8000 Add error reporting sample for manual reporting · johnmanong/python-docs-samples@618d19c · GitHub
[go: up one dir, main page]

Skip to content

Commit 618d19c

Browse files
committed
Add error reporting sample for manual reporting
1 parent eb22abb commit 618d19c

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

error_reporting/report_exception.py

Lines 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

Lines 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