MCPcopy Create free account
hub / github.com/nlweb-ai/NLWeb / create_error_message

Function create_error_message

AskAgent/python/core/schemas.py:380–408  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

378
379
380def 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
411def create_complete_message(handler=None,

Callers 1

_send_error_messageMethod · 0.90

Calls 3

to_dictMethod · 0.95
MessageClass · 0.70
send_messageMethod · 0.45

Tested by

no test coverage detected