-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexample.py
More file actions
51 lines (36 loc) · 1.03 KB
/
example.py
File metadata and controls
51 lines (36 loc) · 1.03 KB
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
49
50
51
import os
from hawkcatcher import Hawk
from dotenv import load_dotenv
load_dotenv() # take environment variables from .env.
class InvalidToken(Exception):
pass
class TestModule:
def __init__(self, hawk):
self.hawk = hawk
@staticmethod
def divide_by_zero():
return 1 / 0
def test_method(self):
self.divide_by_zero()
def mannual_sending(self):
self.hawk.send(ValueError("lol"), {"ping": "pong", "number": 1})
def send_custom_error(self):
raise InvalidToken()
def send_with_user(self):
self.hawk.send(
ValueError("USER"),
None,
{'id': 1, 'name': 'Alice'}
)
def main():
token = os.getenv('HAWK_TOKEN')
if token is None or token == "":
print('Hawk token not provided. Please provide HAWK_TOKEN variable in .env file')
return
hawk = Hawk(token)
test = TestModule(hawk)
test.mannual_sending()
test.send_with_user()
test.send_custom_error()
if __name__ == "__main__":
main()