exceptions.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # pylint: disable=super-init-not-called
  2. from django.core.exceptions import PermissionDenied
  3. from social_core.exceptions import AuthException
  4. class AjaxError(Exception):
  5. """You've tried to do something over AJAX but misago blurped"""
  6. def __init__(self, message=None, code=406):
  7. self.message = message
  8. self.code = code
  9. class Banned(PermissionDenied):
  10. def __init__(self, ban=None):
  11. if ban:
  12. self.ban = ban
  13. class SocialAuthFailed(AuthException):
  14. """Exception used to return error messages from Misago's social auth to user."""
  15. def __init__(self, backend, message):
  16. self.backend = backend
  17. self.message = message
  18. class SocialAuthBanned(AuthException):
  19. """Exception used to return ban message from Misago's social auth to user."""
  20. def __init__(self, backend, ban):
  21. self.backend = backend
  22. self.ban = ban
  23. class ExplicitFirstPage(Exception):
  24. """The url that was used to reach view contained explicit first page"""
  25. class OutdatedSlug(Exception):
  26. """The url that was used to reach view contained outdated slug"""