[ English | 中文 (简体, 中国) | русский | português (Brasil) | नेपाली | 한국어 (대한민국) | Indonesia | français | español | esperanto | English (United Kingdom) | Deutsch ]
Horizon Exceptions¶
Exceptions raised by the Horizon code and the machinery for handling them.
- exception horizon.exceptions.AlreadyExists(name, resource_type)[исходный код]¶
API resources tried to create already exists.
- exception horizon.exceptions.BadRequest[исходный код]¶
Generic error to replace all «BadRequest»-type API errors.
- exception horizon.exceptions.ConfigurationError[исходный код]¶
Exception to be raised when invalid settings have been provided.
- exception horizon.exceptions.Conflict[исходный код]¶
Generic error to replace all «Conflict»-type API errors.
- exception horizon.exceptions.GetFileError(name, resource_type)[исходный код]¶
Exception to be raised when the value of get_file is not expected.
The expected values start with https:// or http://. Otherwise this exception will be raised.
- exception horizon.exceptions.HandledException(wrapped)[исходный код]¶
Used internally to track exceptions that are already handled.
It is used to track exceptions that have gone through
horizon.exceptions.handle()
more than once.
- exception horizon.exceptions.HorizonException[исходный код]¶
Base exception class for distinguishing our own exception classes.
- class horizon.exceptions.HorizonReporterFilter[исходный код]¶
Error report filter that’s always active, even in DEBUG mode.
- is_active(request)[исходный код]¶
This filter is to add safety in production environments (i.e. DEBUG is False). If DEBUG is True then your site is not safe anyway. This hook is provided as a convenience to easily activate or deactivate the filter on a per request basis.
- exception horizon.exceptions.Http302(location, message=None)[исходный код]¶
Exception used to redirect at the middleware level.
This error class which can be raised from within a handler to cause an early bailout and redirect at the middleware level.
- exception horizon.exceptions.MessageFailure[исходный код]¶
Exception raised during message notification.
- exception horizon.exceptions.NotAuthenticated[исходный код]¶
Raised when a user is trying to make requests and they are not logged in.
The included
HorizonMiddleware
catchesNotAuthenticated
and handles it gracefully by displaying an error message and redirecting the user to a login page.
- exception horizon.exceptions.NotAuthorized[исходный код]¶
User tries to access a resource without sufficient permissions.
Raised whenever a user attempts to access a resource which they do not have permission-based access to (such as when failing the
require_perms()
decorator).The included
HorizonMiddleware
catchesNotAuthorized
and handles it gracefully by displaying an error message and redirecting the user to a login page.
- exception horizon.exceptions.NotAvailable[исходный код]¶
Exception to be raised when something is not available.
- exception horizon.exceptions.NotFound[исходный код]¶
Generic error to replace all «Not Found»-type API errors.
- exception horizon.exceptions.RecoverableError[исходный код]¶
Generic error to replace any «Recoverable»-type API errors.
- exception horizon.exceptions.ServiceCatalogException(service_name)[исходный код]¶
A requested service is not available in the
ServiceCatalog
.ServiceCatalog
is fetched from Keystone.
- exception horizon.exceptions.WorkflowError[исходный код]¶
Exception to be raised when something goes wrong in a workflow.
- exception horizon.exceptions.WorkflowValidationError[исходный код]¶
Exception raised during workflow validation.
It is raised if required data is missing, or existing data is not valid.
- horizon.exceptions.handle(request, message=None, redirect=None, ignore=False, escalate=False, log_level=None, force_log=None, details=None)[исходный код]¶
Centralized error handling for Horizon.
Because Horizon consumes so many different APIs with completely different
Exception
types, it’s necessary to have a centralized place for handling exceptions which may be raised.Exceptions are roughly divided into 3 types:
UNAUTHORIZED
: Errors resulting from authentication or authorization problems. These result in being logged out and sent to the login screen.NOT_FOUND
: Errors resulting from objects which could not be located via the API. These generally result in a user-facing error message, but are otherwise returned to the normal code flow. Optionally a redirect value may be passed to the error handler so users are returned to a different view than the one requested in addition to the error message.RECOVERABLE
: Generic API errors which generate a user-facing message but drop directly back to the regular code flow.
All other exceptions bubble the stack as normal unless the
ignore
argument is passed in asTrue
, in which case only unrecognized errors are bubbled.If the exception is not re-raised, an appropriate wrapper exception class indicating the type of exception that was encountered will be returned. If details is None (default), take it from exception sys.exc_info. If details is other string, then use that string explicitly or if details is empty then suppress it.