seitime-frappe/frappe/exceptions.py
tundebabzy be7be766be Issue 3171 (#3178)
* adds new exception to be raised when any improper database configuration is detected

* changes behavior of `check_if_ready_for_barracuda` to raise ImproperDBConfigurationError instead of sys.exit`

* refactors `drop_site` to use a new exactly identical `_drop_site` function.

The reason for this is because the original `drop_site` function is decorated
and cannot be undecorated without nasty hacks. Breaking the function this way
allows me to make use of the `drop-site` logic easily.

* catches the ImproperDBConfigurationError raised from `check_if_ready_for_barracuda` function to drop all the artifacts of the failed new `Site`
2017-05-08 16:06:33 +05:30

82 lines
2.4 KiB
Python

# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt
from __future__ import unicode_literals
# BEWARE don't put anything in this file except exceptions
from werkzeug.exceptions import NotFound
from MySQLdb import ProgrammingError as SQLError, Error
class ValidationError(Exception):
http_status_code = 417
class AuthenticationError(Exception):
http_status_code = 401
class SessionExpired(Exception):
http_status_code = 401
class PermissionError(Exception):
http_status_code = 403
class DoesNotExistError(ValidationError):
http_status_code = 404
class NameError(Exception):
http_status_code = 409
class OutgoingEmailError(Exception):
http_status_code = 501
class SessionStopped(Exception):
http_status_code = 503
class UnsupportedMediaType(Exception):
http_status_code = 415
class Redirect(Exception):
http_status_code = 301
class CSRFTokenError(Exception):
http_status_code = 400
class ImproperDBConfigurationError(Error):
"""
Used when frappe detects that database or tables are not properly
configured
"""
def __init__(self, reason, msg=None):
if not msg:
msg = "MariaDb is not properly configured"
super(ImproperDBConfigurationError, self).__init__(msg)
self.reason = reason
class DuplicateEntryError(NameError):pass
class DataError(ValidationError): pass
class UnknownDomainError(Exception): pass
class MappingMismatchError(ValidationError): pass
class InvalidStatusError(ValidationError): pass
class MandatoryError(ValidationError): pass
class InvalidSignatureError(ValidationError): pass
class RateLimitExceededError(ValidationError): pass
class CannotChangeConstantError(ValidationError): pass
class CharacterLengthExceededError(ValidationError): pass
class UpdateAfterSubmitError(ValidationError): pass
class LinkValidationError(ValidationError): pass
class CancelledLinkError(LinkValidationError): pass
class DocstatusTransitionError(ValidationError): pass
class TimestampMismatchError(ValidationError): pass
class EmptyTableError(ValidationError): pass
class LinkExistsError(ValidationError): pass
class InvalidEmailAddressError(ValidationError): pass
class TemplateNotFoundError(ValidationError): pass
class UniqueValidationError(ValidationError): pass
class AppNotInstalledError(ValidationError): pass
class IncorrectSitePath(NotFound): pass
class ImplicitCommitError(ValidationError): pass
class RetryBackgroundJobError(Exception): pass
class DocumentLockedError(ValidationError): pass