Permalink
Browse files

Merge pull request #836 from davidjb/public-predicate-mismatch

Document PredicateMismatch for exception contexts
  • Loading branch information...
mcdonc committed Feb 10, 2013
2 parents 38db078 + 4d059a7 commit 65cf215b75909f3b2624150c432d5355af7384da
Showing with 25 additions and 5 deletions.
  1. +2 −0 docs/api/exceptions.rst
  2. +23 −5 pyramid/exceptions.py
View
@@ -5,6 +5,8 @@
.. automodule:: pyramid.exceptions
+ .. autoclass:: PredicateMismatch
+
.. autoclass:: Forbidden
.. autoclass:: NotFound
View
@@ -10,11 +10,29 @@
class PredicateMismatch(HTTPNotFound):
"""
- Internal exception (not an API) raised by multiviews when no
- view matches. This exception subclasses the ``NotFound``
- exception only one reason: if it reaches the main exception
- handler, it should be treated like a ``NotFound`` by any exception
- view registrations.
+ This exception is raised by multiviews when no view matches
+ all given predicates.
+
+ This exception subclasses the :class:`HTTPNotFound` exception for a
+ specific reason: if it reaches the main exception handler, it should
+ be treated as :class:`HTTPNotFound`` by any exception view
+ registrations. Thus, typically, this exception will not be seen
+ publicly.
+
+ However, this exception will be raised if the predicates of all
+ views configured to handle another exception context cannot be
+ successfully matched. For instance, if a view is configured to
+ handle a context of ``HTTPForbidden`` and the configured with
+ additional predicates, then :class:`PredicateMismatch` will be
+ raised if:
+
+ * An original view callable has raised :class:`HTTPForbidden` (thus
+ invoking an exception view); and
+ * The given request fails to match all predicates for said
+ exception view associated with :class:`HTTPForbidden`.
+
+ The same applies to any type of exception being handled by an
+ exception view.
"""
class URLDecodeError(UnicodeDecodeError):

0 comments on commit 65cf215

Please sign in to comment.