Skip to content

Commit

Permalink
Add error reporting sample for manual reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewsg committed Nov 3, 2017
1 parent eb22abb commit 618d19c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
16 changes: 13 additions & 3 deletions error_reporting/report_exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# [START error_reporting]
from google.cloud import error_reporting


# [START error_reporting]
def simulate_error():
from google.cloud import error_reporting

client = error_reporting.Client()
try:
# simulate calling a method that's not defined
Expand All @@ -26,5 +26,15 @@ def simulate_error():
# [END error_reporting]


# [START error_reporting_manual]
def report_manual_error():
from google.cloud import error_reporting

client = error_reporting.Client()
client.report("An error has occurred.")
# [END error_reporting_manual]


if __name__ == '__main__':
simulate_error()
report_manual_error()
9 changes: 4 additions & 5 deletions error_reporting/report_exception_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import pytest

import report_exception


@pytest.mark.xfail(
strict=True,
reason='GoogleCloudPlatform/google-cloud-python#3263')
def test_error_sends():
report_exception.simulate_error()


def test_manual_error_sends():
report_exception.report_manual_error()

0 comments on commit 618d19c

Please sign in to comment.