Files
mealie/mealie/core/exceptions.py
Hayden 84c23765cd fix: strict optional errors (#1759)
* fix strict optional errors

* fix typing in repository

* fix backup db files location

* update workspace settings
2022-10-23 13:04:04 -08:00

43 lines
1.1 KiB
Python

from sqlite3 import IntegrityError
from mealie.lang.providers import Translator
class UnexpectedNone(Exception):
"""Exception raised when a value is None when it should not be."""
def __init__(self, message: str = "Unexpected None Value"):
self.message = message
super().__init__(self.message)
def __str__(self):
return f"{self.message}"
class PermissionDenied(Exception):
"""
This exception is raised when a user tries to access a resource that they do not have permission to access.
"""
pass
class NoEntryFound(Exception):
"""
This exception is raised when a user tries to access a resource that does not exist.
"""
pass
def mealie_registered_exceptions(t: Translator) -> dict:
"""
This function returns a dictionary of all the globally registered exceptions in the Mealie application.
"""
return {
PermissionDenied: t.t("exceptions.permission-denied"),
NoEntryFound: t.t("exceptions.no-entry-found"),
IntegrityError: t.t("exceptions.integrity-error"),
}