mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-10-28 00:34:47 -04:00
* fix strict optional errors * fix typing in repository * fix backup db files location * update workspace settings
43 lines
1.1 KiB
Python
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"),
|
|
}
|