File: example.py

package info (click to toggle)
python-opentelemetry 1.39.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,952 kB
  • sloc: python: 53,083; sh: 398; makefile: 142; sql: 39
file content (29 lines) | stat: -rw-r--r-- 529 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from opentelemetry.sdk.error_handler import GlobalErrorHandler

# ZeroDivisionError to be handled by ErrorHandler0
with GlobalErrorHandler():
    1 / 0

print()

# IndexError to be handled by ErrorHandler1
with GlobalErrorHandler():
    [1][2]

print()

# KeyError to be handled by ErrorHandler1
with GlobalErrorHandler():
    {1: 2}[2]

print()

# AssertionError to be handled by DefaultErrorHandler
with GlobalErrorHandler():
    assert False

print()

# No error raised
with GlobalErrorHandler():
    print("No error raised")