-
Notifications
You must be signed in to change notification settings - Fork 0
/
custom_exceptions.py
38 lines (31 loc) · 1023 Bytes
/
custom_exceptions.py
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
''' Useful for formatting messages to print nicely with behave '''
# pylint: disable=consider-using-f-string
def loop_thru_messages(messages):
'''
loops through a list of messages and formats it into a string
seperated by new lines
'''
value = ''
for message in messages:
value += '\r\n' + str(message)
return str(value)
def dictionary_printer(dictionary):
'''
loops through a dictioinary and adds the values to a string,
seperated by new lines
'''
value = ''
for key in dictionary:
value += '\r\n{} - {}'.format(key, dictionary[key])
return str(value)
class LoopThruMessagesException(Exception):
'''
loops through a list of messages and formats it into a string
seperated by new lines but callable on exception.
'''
def __init__(self, messages):
self.value = ''
for message in messages:
self.value += '\r\n' + str(message)
def __str__(self):
return str(self.value)