asException

Converts the current AgentServiceError instance into a corresponding AgentEngineException instance.

This function maps the type property of the AgentServiceError to a specific subclass of AgentEngineException based on the error type. Each error type corresponds to a specific exception:

  • UNEXPECTED_ERROR maps to UnexpectedServerException.

  • UNEXPECTED_MESSAGE_TYPE maps to UnexpectedMessageTypeException.

  • MALFORMED_MESSAGE maps to MalformedMessageException.

  • AGENT_NOT_FOUND maps to AgentNotFoundException.

The message property of the AgentServiceError is passed as the exception's message.

Return

An AgentEngineException instance that corresponds to the current error type.