prefect.exceptions
Prefect-specific exceptions.
Abort
Raised when the API sends an 'ABORT' instruction during state proposal.
Indicates that the run should exit immediately.
Source code in prefect/exceptions.py
class Abort(PrefectSignal):
"""
Raised when the API sends an 'ABORT' instruction during state proposal.
Indicates that the run should exit immediately.
"""
pass
FlowScriptError
Raised when a script errors during evaluation while attempting to load a flow.
Source code in prefect/exceptions.py
class FlowScriptError(PrefectException):
"""
Raised when a script errors during evaluation while attempting to load a flow.
"""
def __init__(
self,
user_exc: Exception,
script_path: str,
) -> None:
message = f"Flow script at {script_path!r} encountered an exception"
super().__init__(message)
self.user_exc = user_exc
def rich_user_traceback(self, **kwargs):
trace = Traceback.extract(
type(self.user_exc),
self.user_exc,
self.user_exc.__traceback__.tb_next.tb_next.tb_next.tb_next,
)
return Traceback(trace, **kwargs)
InvalidNameError
Raised when a name contains characters that are not permitted.
Source code in prefect/exceptions.py
class InvalidNameError(PrefectException, ValueError):
"""
Raised when a name contains characters that are not permitted.
"""
pass
MissingContextError
Raised when a method is called that requires a task or flow run context to be active but one cannot be found.
Source code in prefect/exceptions.py
class MissingContextError(PrefectException, RuntimeError):
"""
Raised when a method is called that requires a task or flow run context to be
active but one cannot be found.
"""
pass
MissingDeploymentError
Raised when a given deployment name is not found in the expected script.
Source code in prefect/exceptions.py
class MissingDeploymentError(PrefectException):
"""
Raised when a given deployment name is not found in the expected script.
"""
pass
MissingFlowError
Raised when a given flow name is not found in the expected script.
Source code in prefect/exceptions.py
class MissingFlowError(PrefectException):
"""
Raised when a given flow name is not found in the expected script.
"""
pass
MissingProfileError
Raised when a profile name does not exist.
Source code in prefect/exceptions.py
class MissingProfileError(PrefectException, ValueError):
"""
Raised when a profile name does not exist.
"""
pass
ObjectAlreadyExists
Raised when the client receives a 409 (conflict) from the API.
Source code in prefect/exceptions.py
class ObjectAlreadyExists(PrefectException):
"""
Raised when the client receives a 409 (conflict) from the API.
"""
def __init__(self, http_exc: Exception, *args, **kwargs):
self.http_exc = http_exc
super().__init__(*args, **kwargs)
ObjectNotFound
Raised when the client receives a 404 (not found) from the API.
Source code in prefect/exceptions.py
class ObjectNotFound(PrefectException):
"""
Raised when the client receives a 404 (not found) from the API.
"""
def __init__(self, http_exc: Exception, *args, **kwargs):
self.http_exc = http_exc
super().__init__(*args, **kwargs)
ParameterTypeError
Raised when a value passed as a flow parameter does not pass validation.
Source code in prefect/exceptions.py
class ParameterTypeError(PrefectException):
"""
Raised when a value passed as a flow parameter does not pass validation.
"""
pass
PrefectException
Base exception type for Prefect errors.
Source code in prefect/exceptions.py
class PrefectException(Exception):
"""
Base exception type for Prefect errors.
"""
pass
PrefectSignal
Base type for signal-like exceptions that should never be caught by users.
Source code in prefect/exceptions.py
class PrefectSignal(BaseException):
"""
Base type for signal-like exceptions that should never be caught by users.
"""
pass
ReservedArgumentError
Raised when a function used with Prefect has an argument with a name that is reserved for a Prefect feature
Source code in prefect/exceptions.py
class ReservedArgumentError(PrefectException, TypeError):
"""
Raised when a function used with Prefect has an argument with a name that is
reserved for a Prefect feature
"""
pass
ScriptError
Raised when a script errors during evaluation while attempting to load data
Source code in prefect/exceptions.py
class ScriptError(PrefectException):
"""
Raised when a script errors during evaluation while attempting to load data
"""
def __init__(
self,
user_exc: Exception,
path: str,
) -> None:
message = f"Script at {str(path)!r} encountered an exception"
super().__init__(message)
self.user_exc = user_exc
import runpy
# Strip script run information from the traceback
self.user_exc.__traceback__ = _trim_traceback(
self.user_exc.__traceback__,
remove_modules=[prefect.utilities.importtools, runpy],
)
SpecValidationError
Raised when a value for a specification is inorrect
Source code in prefect/exceptions.py
class SpecValidationError(PrefectException, ValueError):
"""
Raised when a value for a specification is inorrect
"""
pass
UnspecifiedDeploymentError
Raised when multiple deployments are found in the expected script and no name is given.
Source code in prefect/exceptions.py
class UnspecifiedDeploymentError(PrefectException):
"""
Raised when multiple deployments are found in the expected script and no name is given.
"""
pass
UnspecifiedFlowError
Raised when multiple flows are found in the expected script and no name is given.
Source code in prefect/exceptions.py
class UnspecifiedFlowError(PrefectException):
"""
Raised when multiple flows are found in the expected script and no name is given.
"""
pass
UpstreamTaskError
Raised when a task relies on the result of another task but that task is not 'COMPLETE'
Source code in prefect/exceptions.py
class UpstreamTaskError(PrefectException):
"""
Raised when a task relies on the result of another task but that task is not
'COMPLETE'
"""
pass