-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathruntime_error.py
74 lines (56 loc) · 1.9 KB
/
runtime_error.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# -*- coding: utf-8 -*-
from colorama import Fore
WARNING = u'\U000026A0'
class RuntimeErrorCQ:
last_menu_triggered_error = False
last_error_message = ''
last_codequick_route = ''
last_codequick_callback_params = ''
all_errors = []
all_warnings = []
@classmethod
def reset_error_trigger(cls):
cls.last_menu_triggered_error = False
cls.last_error_message = ''
cls.last_codequick_route = ''
cls.last_codequick_callback_params = ''
@classmethod
def print_encountered_errors(cls):
if len(cls.all_errors) == 0:
print('\n* No error encountered')
return 0
print('\n* Encountered errors list:\n')
cnt = 0
for error in cls.all_errors:
print('\t- Error %s' % cnt)
print(error)
cnt += 1
return 1
@classmethod
def print_encountered_warnings(cls):
if len(cls.all_warnings) == 0:
print('\n* No warning encountered')
return 0
print('\n* Encountered warnings list:\n')
cnt = 0
for error in cls.all_warnings:
print('\t- Warning %s' % cnt)
print(error)
cnt += 1
return 1
def __init__(self, path):
self.route = RuntimeErrorCQ.last_codequick_route
self.params = dict(RuntimeErrorCQ.last_codequick_callback_params)
self.msg = RuntimeErrorCQ.last_error_message
self.pp_path = str(path)
if 'RuntimeError: No items found' in self.msg:
RuntimeErrorCQ.all_warnings.append(self)
else:
RuntimeErrorCQ.all_errors.append(self)
def __str__(self):
s = ''
s += '* Path: {}'.format(self.pp_path) + '\n'
s += '* Route: {}'.format(self.route) + '\n'
s += '* Params: {}'.format(self.params) + '\n'
s += '* Message: \n{}'.format(self.msg) + '\n'
return s