Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Document PredicateMismatch for exception contexts

  • Loading branch information...
commit 4d059a786bc019673715754be58fd61dd8d5359c 1 parent 2bee326
@davidjb davidjb authored
Showing with 25 additions and 5 deletions.
  1. +2 −0  docs/api/exceptions.rst
  2. +23 −5 pyramid/exceptions.py
View
2  docs/api/exceptions.rst
@@ -5,6 +5,8 @@
.. automodule:: pyramid.exceptions
+ .. autoclass:: PredicateMismatch
+
.. autoclass:: Forbidden
.. autoclass:: NotFound
View
28 pyramid/exceptions.py
@@ -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):
Please sign in to comment.
Something went wrong with that request. Please try again.