The horizon.exceptions ModuleΒΆ
Exceptions raised by the Horizon code and the machinery for handling them.
-
exception
horizon.exceptions.AlreadyExists(name, resource_type)[source] Bases:
horizon.exceptions.HorizonExceptionException to be raised when trying to create an API resource which already exists.
-
exception
horizon.exceptions.BadRequest[source] Bases:
horizon.exceptions.HorizonExceptionGeneric error to replace all “BadRequest”-type API errors.
-
status_code= 400
-
-
exception
horizon.exceptions.ConfigurationError[source] Bases:
horizon.exceptions.HorizonExceptionException to be raised when invalid settings have been provided.
-
exception
horizon.exceptions.Conflict[source] Bases:
horizon.exceptions.HorizonExceptionGeneric error to replace all “Conflict”-type API errors.
-
status_code= 409
-
-
exception
horizon.exceptions.GetFileError(name, resource_type)[source] Bases:
horizon.exceptions.HorizonExceptionException to be raised when the value of get_file did not start with https:// or http://
-
exception
horizon.exceptions.HandledException(wrapped)[source] Bases:
horizon.exceptions.HorizonExceptionUsed internally to track exceptions that have gone through
horizon.exceptions.handle()more than once.
-
exception
horizon.exceptions.HorizonException[source] Bases:
exceptions.ExceptionBase exception class for distinguishing our own exception classes.
-
class
horizon.exceptions.HorizonReporterFilter[source] Bases:
django.views.debug.SafeExceptionReporterFilterError report filter that’s always active, even in DEBUG mode.
-
is_active(request)[source]
-
-
exception
horizon.exceptions.Http302(location, message=None)[source] Bases:
horizon.exceptions.HorizonExceptionError class which can be raised from within a handler to cause an early bailout and redirect at the middleware level.
-
status_code= 302
-
-
exception
horizon.exceptions.MessageFailure[source] Bases:
horizon.exceptions.HorizonExceptionException raised during message notification.
-
exception
horizon.exceptions.NotAuthenticated[source] Bases:
horizon.exceptions.HorizonExceptionRaised when a user is trying to make requests and they are not logged in.
The included
HorizonMiddlewarecatchesNotAuthenticatedand handles it gracefully by displaying an error message and redirecting the user to a login page.-
status_code= 403
-
-
exception
horizon.exceptions.NotAuthorized[source] Bases:
horizon.exceptions.HorizonExceptionRaised 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
HorizonMiddlewarecatchesNotAuthorizedand handles it gracefully by displaying an error message and redirecting the user to a login page.-
status_code= 401
-
-
exception
horizon.exceptions.NotAvailable[source] Bases:
horizon.exceptions.HorizonExceptionException to be raised when something is not available.
-
exception
horizon.exceptions.NotFound[source] Bases:
horizon.exceptions.HorizonExceptionGeneric error to replace all “Not Found”-type API errors.
-
status_code= 404
-
-
exception
horizon.exceptions.RecoverableError[source] Bases:
horizon.exceptions.HorizonExceptionGeneric error to replace any “Recoverable”-type API errors.
-
status_code= 100
-
-
exception
horizon.exceptions.ServiceCatalogException(service_name)[source] Bases:
horizon.exceptions.HorizonExceptionRaised when a requested service is not available in the
ServiceCatalogreturned by Keystone.
-
exception
horizon.exceptions.WorkflowError[source] Bases:
horizon.exceptions.HorizonExceptionException to be raised when something goes wrong in a workflow.
-
exception
horizon.exceptions.WorkflowValidationError[source] Bases:
horizon.exceptions.HorizonExceptionException raised during workflow validation if required data is missing, or existing data is not valid.
-
horizon.exceptions.check_message(keywords, message)[source] Checks an exception for given keywords and raises a new
ActionErrorwith the desired message if the keywords are found. This allows selective control over API error messages.
-
horizon.exceptions.error_color(msg)[source]
-
horizon.exceptions.handle(request, message=None, redirect=None, ignore=False, escalate=False, log_level=None, force_log=None)[source] Centralized error handling for Horizon.
Because Horizon consumes so many different APIs with completely different
Exceptiontypes, 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
ignoreargument 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.
-
horizon.exceptions.handle_notfound(request, message, redirect, ignore, escalate, handled, force_silence, force_log, log_method, log_entry, log_level)[source]
-
horizon.exceptions.handle_recoverable(request, message, redirect, ignore, escalate, handled, force_silence, force_log, log_method, log_entry, log_level)[source]
-
horizon.exceptions.handle_unauthorized(request, message, redirect, ignore, escalate, handled, force_silence, force_log, log_method, log_entry, log_level)[source]