Create an error message. Args: error_text: The error message text handler: Handler instance (provides conversation_id and send capability) metadata: Optional error metadata send: If True and handler provided, automatically send the message Returns:
(error_text: str,
handler=None,
metadata: dict[str, Any] | None = None,
send: bool = True)
| 378 | |
| 379 | |
| 380 | def create_error_message(error_text: str, |
| 381 | handler=None, |
| 382 | metadata: dict[str, Any] | None = None, |
| 383 | send: bool = True) -> Message: |
| 384 | """ |
| 385 | Create an error message. |
| 386 | |
| 387 | Args: |
| 388 | error_text: The error message text |
| 389 | handler: Handler instance (provides conversation_id and send capability) |
| 390 | metadata: Optional error metadata |
| 391 | send: If True and handler provided, automatically send the message |
| 392 | |
| 393 | Returns: |
| 394 | The created Message object |
| 395 | """ |
| 396 | message = Message( |
| 397 | sender_type=SenderType.SYSTEM, |
| 398 | message_type=MessageType.ERROR, |
| 399 | content=error_text, |
| 400 | conversation_id=handler.conversation_id if handler and hasattr(handler, 'conversation_id') else None, |
| 401 | metadata=metadata |
| 402 | ) |
| 403 | |
| 404 | if send and handler: |
| 405 | import asyncio |
| 406 | asyncio.create_task(handler.send_message(message.to_dict())) |
| 407 | |
| 408 | return message |
| 409 | |
| 410 | |
| 411 | def create_complete_message(handler=None, |
no test coverage detected