Skip to content

Commit 96e780d

Browse files
Merge pull request #29 from MasoniteFramework/fix/27
Fix/27
2 parents 867896f + 4e99e0b commit 96e780d

File tree

5 files changed

+55
-2
lines changed

5 files changed

+55
-2
lines changed

src/exceptionite/blocks/PossibleSolutions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def __init__(self, tab, handler, options):
2323
solutions.DictionaryUpdateSequence(),
2424
solutions.DictionaryUpdateSequenceWithList(),
2525
solutions.UnsupportedOperand(),
26+
solutions.DivisionByZeroError(),
2627
solutions.ContainerKeyNotFoundServiceProvider(),
2728
solutions.ContainerKeyNotFoundRegister(),
2829
solutions.ClassMethodExists(),
@@ -87,7 +88,7 @@ def get_request_link(self):
8788
"body": f"A solution is missing:\nException namespace: `{self.handler.namespace()}`\nError message:\n```\n{self.handler.message()}\n```", # noqa: E501
8889
"label": "solution-request",
8990
}
90-
return f"https://github.com/MasoniteFramework/masonite/issues/new/?{urllib.parse.urlencode(params)}" # noqa: E501
91+
return f"https://github.com/MasoniteFramework/exceptionite/issues/new/?{urllib.parse.urlencode(params)}" # noqa: E501
9192

9293
def register(self, *solutions):
9394
self.registered_solutions += solutions
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
from .. import Handler, Block
2+
3+
4+
5+
6+
class ContextBlock(Block):
7+
id = "django-request"
8+
name = "Context"
9+
icon = "DesktopComputerIcon"
10+
has_sections = True
11+
12+
13+
def build(self):
14+
from django.utils.version import get_version
15+
return {
16+
"Django": {
17+
"Version": get_version(),
18+
},
19+
"Request Info": {
20+
"Path": self.handler.request.path,
21+
"GET": self.handler.request.GET,
22+
"POST": self.handler.request.POST,
23+
"Files": self.handler.request.FILES,
24+
"Cookies": self.handler.request.COOKIES,
25+
"Request Method": self.handler.request.method,
26+
},
27+
}
28+
29+
class ExceptioniteReporter:
30+
31+
def __init__(self, request, exc_type, exc_value, tb):
32+
self.request = request
33+
self.exception = exc_value
34+
35+
def get_traceback_html(self):
36+
handler = Handler()
37+
handler.start(self.exception)
38+
handler.render("terminal")
39+
handler.request = self.request
40+
handler.renderer("web").tab("context").add_blocks(ContextBlock)
41+
return handler.render("web")

src/exceptionite/django/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .ExceptioniteReporter import ExceptioniteReporter

src/exceptionite/options.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"repo": "https://github.com/MasoniteFramework/masonite",
88
},
99
"stack": {"offset": 8, "shorten": True},
10-
"hide_sensitive_data": True
10+
"hide_sensitive_data": True,
1111
},
1212
"handlers": {
1313
"context": True,

src/exceptionite/solutions.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,16 @@ def description(self):
192192
def regex(self):
193193
return r"unsupported operand type\(s\) for \+\: '(?P<type1>([\w\.]*))' and '(?P<type2>([\w\.]*))'"
194194

195+
class DivisionByZeroError:
196+
def title(self):
197+
return "Check variables for any values that could be 0"
198+
199+
def description(self):
200+
return "Check any place you are doing division. You cannot divide by a zero."
201+
202+
def regex(self):
203+
return r"division by zero"
204+
195205

196206
class ContainerKeyNotFoundRegister:
197207
def title(self):

0 commit comments

Comments
 (0)