-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexample2.py
More file actions
48 lines (34 loc) · 993 Bytes
/
example2.py
File metadata and controls
48 lines (34 loc) · 993 Bytes
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import hawkcatcher
import os
from dotenv import load_dotenv
load_dotenv() # take environment variables from .env.
class InvalidToken(Exception):
pass
class Module:
@staticmethod
def divide_by_zero():
return 1 / 0
def test_method(self):
self.divide_by_zero()
def mannual_sending(self):
hawkcatcher.send(ValueError("lol"), {"ping": "pong", "number": 1})
def send_custom_error(self):
raise InvalidToken()
def send_with_user(self):
hawkcatcher.send(
ValueError("USER"),
None,
{'id': 1, 'name': 'Alice'}
)
def main():
token = os.getenv('HAWK_TOKEN')
if token is None or token == "":
print('hawkcatcher token not provided. Please provide HAWK_TOKEN variable in .env file')
return
hawkcatcher.init(token)
test = Module()
test.mannual_sending()
test.send_with_user()
test.send_custom_error()
if __name__ == "__main__":
main()