summaryrefslogtreecommitdiff
path: root/jsonschema/exceptions.py
diff options
context:
space:
mode:
authorJohn Anderson <sontek@gmail.com>2013-10-17 20:19:57 -0700
committerJohn Anderson <sontek@gmail.com>2013-10-17 20:19:57 -0700
commit1963981389d3a8e462af935f9e82759ff17654ae (patch)
tree377d48dd5c119bfa506a1878b0b53ff2a897381d /jsonschema/exceptions.py
parentb6ede007ae7a6b57cf775776337d09261ddc3134 (diff)
downloadjsonschema-1963981389d3a8e462af935f9e82759ff17654ae.tar.gz
Clean up the output when an unknow type is found
Diffstat (limited to 'jsonschema/exceptions.py')
-rw-r--r--jsonschema/exceptions.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/jsonschema/exceptions.py b/jsonschema/exceptions.py
index f1d3e42..b24478a 100644
--- a/jsonschema/exceptions.py
+++ b/jsonschema/exceptions.py
@@ -93,7 +93,28 @@ class RefResolutionError(Exception):
class UnknownType(Exception):
- pass
+ def __init__(self, type, instance, schema):
+ self.type = type
+ self.instance = instance
+ self.schema = schema
+ self.msg = "OMGZ"
+
+ def __str__(self):
+ return self.__unicode__()
+
+ def __unicode__(self):
+ pschema = pprint.pformat(self.schema, width=72)
+ pinstance = pprint.pformat(self.instance, width=72)
+ return textwrap.dedent("""
+ unknown type %s, in schema:
+ %r
+
+ On instance:
+ %s
+ """.rstrip()
+ ) % (self.type, self.schema, self.instance)
+
+
class FormatError(Exception):