| Server IP : 85.214.239.14 / Your IP : 216.73.216.27 Web Server : Apache/2.4.65 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Mon Sep 30 15:36:27 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 8.2.29 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /proc/3/task/3/root/srv/modoboa/env/lib/python3.5/site-packages/modoboa/lib/ |
Upload File : |
"""
:mod:`exceptions` --- Custom Modoboa exceptions
-----------------------------------------------
"""
from django.utils.translation import ugettext as _
class ModoboaException(Exception):
"""
Base class for Modoboa custom exceptions.
"""
http_code = None
def __init__(self, *args, **kwargs):
if "http_code" in kwargs:
self.http_code = kwargs["http_code"]
del kwargs["http_code"]
super(ModoboaException, self).__init__(*args, **kwargs)
class InternalError(ModoboaException):
"""
Use this exception for system errors, missing dependencies, etc.
"""
http_code = 500
class BadRequest(ModoboaException):
"""
Use this exception when received data doesn't validate a specific
format (example: wrong CSV line) or doesn't respect validation
rules.
"""
http_code = 400
class NotFound(ModoboaException):
"""
Use this exception to indicate the requested resource could not be
found.
"""
http_code = 404
class Conflict(ModoboaException):
"""
Use this exception to indicate that the request could not be
processed because of conflict in the request.
"""
http_code = 409
class PermDeniedException(ModoboaException):
"""
Use this exception when a user tries to do something he is not
allowed to.
"""
http_code = 403
def __init__(self, msg=None):
self.msg = msg
def __str__(self):
if self.msg:
return _("Permission denied: %s" % self.msg)
return _("Permission denied")