File: exceptions.py

package info (click to toggle)
django-dynamic-preferences 1.17.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 476 kB
  • sloc: python: 3,040; makefile: 3
file content (32 lines) | stat: -rw-r--r-- 1,071 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
class DynamicPreferencesException(Exception):
    detail_default = "An exception occurred with django-dynamic-preferences"

    def __init__(self, detail=None):
        if detail is not None:
            self.detail = str(detail)
        else:
            self.detail = str(self.detail_default)

    def __str__(self):
        return self.detail


class MissingDefault(DynamicPreferencesException):
    detail_default = "You must provide a default value for all preferences"


class NotFoundInRegistry(DynamicPreferencesException, KeyError):
    detail_default = "Preference with this name/section not found in registry"


class DoesNotExist(DynamicPreferencesException):
    detail_default = "Cannot retrieve preference value, ensure the preference is correctly registered and database is synced"


class CachedValueNotFound(DynamicPreferencesException):
    detail_default = "Cached value not found"


class MissingModel(DynamicPreferencesException):
    detail_default = 'You must define a model choice through "model" \
                      or "queryset" attribute'