promptflow.exceptions module#

class promptflow.exceptions.ErrorCategory(value)#

Bases: str, Enum

An enumeration.

SYSTEM_ERROR = 'SystemError'#
UNKNOWN = 'Unknown'#
USER_ERROR = 'UserError'#
class promptflow.exceptions.ErrorTarget(value)#

Bases: str, Enum

The target of the error, indicates which part of the system the error occurs.

AZURE_RUN_STORAGE = 'AzureRunStorage'#
BATCH = 'Batch'#
CONTROL_PLANE_SDK = 'ControlPlaneSDK'#
CORE = 'Core'#
EXECUTOR = 'Executor'#
FLOW_EXECUTOR = 'FlowExecutor'#
FLOW_INVOKER = 'FlowInvoker'#
FUNCTION_PATH = 'FunctionPath'#
NODE_EXECUTOR = 'NodeExecutor'#
RUNTIME = 'Runtime'#
RUN_STORAGE = 'RunStorage'#
RUN_TRACKER = 'RunTracker'#
SERVING_APP = 'ServingApp'#
TOOL = 'Tool'#
UNKNOWN = 'Unknown'#
exception promptflow.exceptions.PromptflowException(message='', message_format='', target: ErrorTarget = ErrorTarget.UNKNOWN, module=None, privacy_info: Optional[List[str]] = None, **kwargs)#

Bases: Exception

Base exception for all errors.

Parameters:
  • message (str) – A message describing the error. This is the error message the user will see.

  • target (ErrorTarget) – The name of the element that caused the exception to be thrown.

  • error (Exception) – The original exception if any.

  • privacy_info (List[str]) – To record messages to telemetry, it is necessary to mask private information. If set to None, messages will not be recorded to telemetry. Otherwise, it will replace the content string in messages that contain privacy_info with ‘{privacy_info}’.

property additional_info#

Return a dict of the additional info of the exception.

By default, this information could usually be empty.

However, we can still define additional info for some specific exception. i.e. For ToolExcutionError, we may add the tool’s line number, stacktrace to the additional info.

property error_codes#

Returns a list of the error codes for this exception.

The error codes is defined the same as the class inheritance. i.e. For ToolExcutionError which inherits from UserErrorException, The result would be [“UserErrorException”, “ToolExecutionError”].

get_arguments_from_message_format(message_format)#

Get the arguments from the message format.

property inner_exception#

Get the inner exception.

The inner exception can be set via either style:

  1. Set via the error parameter in the constructor.

    raise PromptflowException(“message”, error=inner_exception)

  2. Set via raise from statement.

    raise PromptflowException(“message”) from inner_exception

property message#

The error message.

property message_format#

The error message format.

property message_parameters#

The error message parameters.

property module#

The module of the error that occurs.

It is similar to target but is more specific. It is meant to store the Python module name of the code that raises the exception.

property reference_code#

The reference code of the error.

property serializable_message_parameters#

The serializable error message parameters.

property target#

The error target.

Returns:

The error target.

Return type:

ErrorTarget

exception promptflow.exceptions.SystemErrorException(message='', message_format='', target: ErrorTarget = ErrorTarget.UNKNOWN, module=None, privacy_info: Optional[List[str]] = None, **kwargs)#

Bases: PromptflowException

Exception raised when service error is triggered.

exception promptflow.exceptions.UserErrorException(message='', message_format='', target: ErrorTarget = ErrorTarget.UNKNOWN, module=None, privacy_info: Optional[List[str]] = None, **kwargs)#

Bases: PromptflowException

Exception raised when invalid or unsupported inputs are provided.

exception promptflow.exceptions.ValidationException(message='', message_format='', target: ErrorTarget = ErrorTarget.UNKNOWN, module=None, privacy_info: Optional[List[str]] = None, **kwargs)#

Bases: UserErrorException

Exception raised when validation fails.