"""This module is a collection of project-wide exceptions.""" class NotFoundException(Exception): """Raised when a resource was unexpectedly not found.""" pass class DataIntegrityException(Exception): """Raised to prevent a semantically invalid database operation.""" pass class InvalidFilterParameterException(Exception): """Raised when a query filter parameter is invalid.""" pass def create_exception_dict(message: str): """Creates a list for returning API error messages to the client. The list has the following format: [ { "msg": "Something went wrong!.", }, ] This is useful to return consistent API error messages. """ if not isinstance(message, str): raise TypeError(f"Expected a string but got '{type(message)}'.") if not len(message): message = "An unknown error occurred." return [{"msg": message}]