class EmailingError(ErrorList): INVALID_ID = get_error(message="Invalid id provided.") INVALID_OBJECT_TYPE = get_error(message="Invalid objectType") INVALID_ACTION = get_error(message="Invalid action for objectType") FIELD_NOT_FOUND = get_error(message="A required field was left empty.") INVALID_CAMPAIGN_START = get_error( message="This campaign must be sent manually.")
class SocialAccountError(ErrorList): GENERIC_INVALID_PROCESS = get_error(message="Invalid login process") INVALID_SOCIAL_TOKEN = get_error(message="Invalid social token") INVALID_SOCIAL_ACCOUNT = get_error(message="Error accessing external account (Facebook/Google/etc.)") SOCIAL_ACCOUNT_NO_EMAIL = get_error(message="Your external account (Facebook/Google/etc.) is not linked to an email address." "We require an email address to log you in.")
class ContentError(ErrorList): TRANSLATION_EXISTS = get_error( message="A translation in this language already exists.") REQUESTED_TOO_MANY_ARTICLES = get_error( message="You have requested too many articles at once.") PROTECTED_ARTICLE = get_error(message="The article is protected.") TOO_MUCH_FEEDBACK = get_error(message="Too many posts, ignoring")
class BaseError(ErrorList): USER_NOT_AUTHENTICATED = get_error(id=1, message="User not authenticated") NOT_ALLOWED = get_error(id=2, message="Not allowed") OBJECT_NOT_FOUND = get_error(id=3, message="Object not found") INVALID_URL = get_error(message="Invalid url") OBJECT_ALREADY_EXISTS = get_error( message="The object you want to create already exists") INVALID_DATA = get_error(message="Validation error") TOO_MANY_OBJECTS = get_error(message="Requesting too many objects") MAINTENANCE = get_error(message="Website in maintenance mode!")
class StorageError(ErrorList): NO_FILES = get_error(message="No files to upload") TOO_MANY_FILES = get_error( message="Too many files to upload at the same time") WILL_EXCEED_FILES_LIMIT = get_error( message="Completion of this request will exceed the maximum " "number of total files you can store") WILL_EXCEED_SIZE_LIMIT = get_error( message="Completion of this request will exceed the maximum " "total size you can store") FILE_TOO_LARGE = get_error( message= "One of the files you are uploading exceeds the maximum size limit") TOO_MANY_GALLERIES = get_error( message="You already have the maximum number of galleries.") INVALID_GALLERY = get_error(message="Invalid gallery id") FULL_GALLERY = get_error(message="Gallery is full") INVALID_SERVER = get_error( message="Internal server error! It appears storage server" " associated with this file does not exists!")
def load_from_db(cls): """ Update all class fields that are ErrorMessage instances with the values from the database. If there's not coresponding DB entry for the given message for instance, a new entry is created. """ try: ErrorMessage.ensure_cache_build() except: # Just log an error here, and carry on print( "Error in loading errors from DB, how ironic, eh? This is expected when error models are not migrated" ) return for attr, value in cls.all(): if not value.is_from_db: value = get_error(**value.__dict__) setattr(cls, attr, value)
class ForumError(ErrorList): INVALID_MESSAGE_CONTENT = get_error(message="Invalid message content") MESSAGE_NOT_EDITABLE = get_error(message="Message not editable") MESSAGE_LIMIT_EXCEEDED = get_error(message="Message limit exceeded") FORUM_THREAD_LIMIT_EXCEEDED = get_error( message="Forum thread limit exceeded") TITLE_TOO_LONG = get_error( message="Forum thread title max length exceeded") INVALID_TITLE = get_error( message= "Invalid title. (forum thread title must contain at least one alpha-numeric character)" )
class MyErrorList(ErrorList): INVALID_MESSAGE_CONTENT = get_error(message="Invalid message content") MESSAGE_NOT_EDITABLE = get_error(message="Message not editable") MESSAGE_LIMIT_EXCEEDED = get_error(message="Message limit exceeded") NEW_PRIVATE_CHAT_LIMIT_EXCEEDED = get_error( message="Too many private chats initiated")
class BaseconfigError(ErrorList): INVALID_COMMAND_INSTANCE = get_error(message="Invalid command instance")
class LocalizationError(ErrorList): EMPTY_TRANSLATION_ENTRY = get_error(message="Entry values cannot be empty") ONE_INVALID_TRANSLATION_KEY = get_error( message="One of the key is not valid") TRANSLATION_KEY_NOT_FOUND = get_error(message="Key doesn't exist") INVALID_TRANSLATION_VALUE = get_error(message="Invalid translation value")
class AccountsError(ErrorList): # Errors due to unavailability of the requested action ALREADY_LOGGED_IN = get_error(message="You're already logged in") EMAIL_UNAVAILABLE = get_error(message="Email address is already in") USERNAME_UNAVAILABLE = get_error(message="Username is already in use") PRIMARY_EMAIL_REMOVAL = get_error( message="Email address is primary, can't remove") # Errors due to invalid information provided INVALID_CAPTCHA = get_error(message="Invalid captcha") INVALID_USERNAME = get_error(message="Username is invalid") INVALID_SOCIAL_ACCOUNT = get_error(message="Social account doesn't exist") INVALID_EMAIL_ADDRESS = get_error(message="Invalid email address") INVALID_LOGIN_CREDENTIALS = get_error( message= "The e-mail address and/or password you specified are not correct") INVALID_SOCIAL_ACCOUNT_REMOVAL = get_error( message="Can't remove social account for other user") WRONG_PASSWORD = get_error(message="Wrong password") MISSING_PASSWORD = get_error(message="Missing password field") INVALID_PASSWORD_RESET_TOKEN = get_error(message="Invalid password token") # Errors due to abuse of services TOO_MANY_PASSWORD_RESETS = get_error( message="You may request another password reset later") TOO_MANY_PROFILES_REQUESTED = get_error( message="Requesting too many users") TOO_MANY_SIGN_UPS = get_error( message="Too many users created from your IP")