exceptions.py 1.1 KB

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