Skip to content

Commit

Permalink
Merge branch '0.15.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
davidism committed Jun 26, 2019
2 parents f753a32 + 7940aa8 commit 1a85242
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/werkzeug/debug/shared/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ div.traceback div.source.expanded span.ws {
display: inline;
}

div.traceback blockquote { margin: 1em 0 0 0; padding: 0; }
div.traceback blockquote { margin: 1em 0 0 0; padding: 0; white-space: pre-line; }
div.traceback img { float: right; padding: 2px; margin: -3px 2px 0 0; display: none; }
div.traceback img:hover { background-color: #ddd; cursor: pointer;
border-color: #BFDDE0; }
Expand Down
23 changes: 14 additions & 9 deletions src/werkzeug/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ def wrap(cls, exception, name=None):
"""

class newcls(cls, exception):
_description = cls.description
show_exception = False

def __init__(self, arg=None, *args, **kwargs):
Expand All @@ -119,18 +120,22 @@ def __init__(self, arg=None, *args, **kwargs):
else:
exception.__init__(self, arg)

def get_description(self, environ=None):
out = super(cls, self).get_description(environ=environ)

if self.show_exception and self.args:
out += "<p><pre><code>{}: {}</code></pre></p>".format(
exception.__name__, escape(exception.__str__(self))
@property
def description(self):
if self.show_exception:
return "{}\n{}: {}".format(
self._description, exception.__name__, exception.__str__(self)
)

return out
return self._description

@description.setter
def description(self, value):
self._description = value

newcls.__module__ = sys._getframe(1).f_globals.get("__name__")
newcls.__name__ = name or cls.__name__ + exception.__name__
name = name or cls.__name__ + exception.__name__
newcls.__name__ = newcls.__qualname__ = name
return newcls

@property
Expand All @@ -140,7 +145,7 @@ def name(self):

def get_description(self, environ=None):
"""Get the description."""
return u"<p>%s</p>" % escape(self.description)
return u"<p>%s</p>" % escape(self.description).replace("\n", "<br>")

def get_body(self, environ=None):
"""Get the HTML body."""
Expand Down

0 comments on commit 1a85242

Please sign in to comment.