ITADN

print error for sql

#67Pull Requestadamwdraper 创建于 2025-04-17已合并
A
adamwdrapercommented
This pull request introduces enhancements to Slack integration, including support for asynchronous operations, improved error handling, and more robust Slack block generation. Key changes include adding an optional `text` parameter to `post_to_slack`, converting `generate_slack_blocks` to an asynchronous function, and refining error handling for invalid Slack block responses. ### Slack Integration Enhancements: * **Optional `text` Parameter in `post_to_slack`:** - Added a `text` parameter to allow explicit fallback content for notifications. If not provided, fallback text is extracted from the first block or defaults to a generic message. (`tyler/tools/slack.py`, [[1]](diffhunk://#diff-2fb51ad496b659bc195746a93a8ae60720c15422881f36c382db8e69906e2fd1L17-R17) [[2]](diffhunk://#diff-2fb51ad496b659bc195746a93a8ae60720c15422881f36c382db8e69906e2fd1R26) [[3]](diffhunk://#diff-2fb51ad496b659bc195746a93a8ae60720c15422881f36c382db8e69906e2fd1L36-R44) * **Asynchronous Slack Block Generation:** - Converted `generate_slack_blocks` to an `async` function, enabling asynchronous API calls with `litellm.acompletion`. The function now returns a dictionary with both `blocks` and `text` for improved accessibility and fallback handling. (`tyler/tools/slack.py`, [tyler/tools/slack.pyL57-R182](diffhunk://#diff-2fb51ad496b659bc195746a93a8ae60720c15422881f36c382db8e69906e2fd1L57-R182)) * **Improved Error Handling in `generate_slack_blocks`:** - Enhanced error handling for invalid JSON responses by attempting to clean and parse the content. If parsing fails, a default error block is returned along with the original content as fallback text. (`tyler/tools/slack.py`, [tyler/tools/slack.pyL57-R182](diffhunk://#diff-2fb51ad496b659bc195746a93a8ae60720c15422881f36c382db8e69906e2fd1L57-R182)) ### Test Updates: * **Updated Tests for `post_to_slack`:** - Modified tests to include the new `text` parameter and verify its behavior. (`tests/tools/test_slack.py`, [tests/tools/test_slack.pyL63-R105](diffhunk://#diff-b2840be7a113f5132c2e5fe52bbd7458e90bb3573c6d61eab7dd8e716cc9da1dL63-R105)) * **Async Test for `generate_slack_blocks`:** - Updated the test for `generate_slack_blocks` to handle asynchronous behavior and validate the new dictionary response structure. (`tests/tools/test_slack.py`, [tests/tools/test_slack.pyL63-R105](diffhunk://#diff-b2840be7a113f5132c2e5fe52bbd7458e90bb3573c6d61eab7dd8e716cc9da1dL63-R105)) ### Miscellaneous: * **Error Message Improvement in Database Save Method:** - Enhanced error messages in `save` method to include the exception details for better debugging. (`tyler/database/storage_backend.py`, [tyler/database/storage_backend.pyL362-R362](diffhunk://#diff-cd3d9820fe4ea35b92b7660c7363b5acd48906ce792d7f0150225350b30e65e8L362-R362))This pull request includes a minor improvement to error logging in the `save` method of the `tyler/database/storage_backend.py` file. The change enhances the error message by including the specific database error details for better debugging. * [`tyler/database/storage_backend.py`](diffhunk://#diff-cd3d9820fe4ea35b92b7660c7363b5acd48906ce792d7f0150225350b30e65e8L362-R362): Updated the `RuntimeError` raised in the `save` method to include the string representation of the database error (`str(e)`) in the error message.
合并状态:已合并 合并于 2025-04-18 关闭于 2025-04-18 0 条评论