Source code for kani.exceptions
[docs]
class KaniException(Exception):
"""Base class for all Kani exceptions/errors."""
# ==== function calling ====
[docs]
class FunctionCallException(KaniException):
"""Base class for exceptions that occur when a model calls an @ai_function."""
def __init__(self, retry: bool):
self.retry = retry
[docs]
class WrappedCallException(FunctionCallException):
"""The @ai_function raised an exception."""
def __init__(self, retry, original):
super().__init__(retry)
self.original = original
def __str__(self):
return str(self.original)
[docs]
class NoSuchFunction(FunctionCallException):
"""The model attempted to call a function that does not exist."""
def __init__(self, name):
super().__init__(True)
self.name = name
# ==== programmer errors ====
[docs]
class FunctionSpecError(KaniException):
"""This @ai_function spec is invalid."""
[docs]
class MissingModelDependencies(KaniException):
"""You are trying to use an engine but do not have engine-specific packages installed."""
[docs]
class PromptError(KaniException):
"""For some reason, the input to this model is invalid."""
# ==== serdes ====
[docs]
class MissingMessagePartType(KaniException):
"""During loading a saved kani, a message part has a type which is not currently defined in the runtime."""
def __init__(self, fqn: str, msg: str):
"""
:param fqn: The fully qualified name of the type that is missing.
"""
super().__init__(msg)
self.fqn = fqn