summaryrefslogtreecommitdiff
path: root/paste/httpexceptions.py
diff options
context:
space:
mode:
authorianb <devnull@localhost>2005-12-21 18:43:35 +0000
committerianb <devnull@localhost>2005-12-21 18:43:35 +0000
commit22bb95b9ee15156ce06b58d5d416d6077bb7ad78 (patch)
tree262667bf74aa25792c275fd73ba5ed24b10151f8 /paste/httpexceptions.py
parent9b855fa4539ad96d8e23f8eb00abe4d7b8f694d6 (diff)
downloadpaste-22bb95b9ee15156ce06b58d5d416d6077bb7ad78.tar.gz
Improve error messages in assertions
Diffstat (limited to 'paste/httpexceptions.py')
-rw-r--r--paste/httpexceptions.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/paste/httpexceptions.py b/paste/httpexceptions.py
index cd08909..5ee0cb0 100644
--- a/paste/httpexceptions.py
+++ b/paste/httpexceptions.py
@@ -152,12 +152,19 @@ class HTTPException(Exception):
def __init__(self, detail=None, headers=None, comment=None):
assert self.code, "Do not directly instantiate abstract exceptions."
- assert isinstance(headers, (type(None), list))
- assert isinstance(detail, (type(None), basestring))
- assert isinstance(comment, (type(None), basestring))
+ assert isinstance(headers, (type(None), list)), (
+ "headers must be None or a list: %r"
+ % headers)
+ assert isinstance(detail, (type(None), basestring)), (
+ "detail must be None or a string: %r" % detail)
+ assert isinstance(comment, (type(None), basestring)), (
+ "comment must be None or a string: %r" % comment)
self.headers = headers or tuple()
for req in self.required_headers:
- assert headers and has_header(headers, req)
+ assert headers and has_header(headers, req), (
+ "Exception %s must be passed the header %r "
+ "(got headers: %r)"
+ % (self.__class__.__name__, req, headers))
if detail is not None:
self.detail = detail
if comment is not None: