-
Notifications
You must be signed in to change notification settings - Fork 326
pipe SQL errors into the existing onError method using a new SqlError class #768
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: 3d7670c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Claude Code ReviewSummary: Clean implementation that properly routes SQL errors through the existing error handling mechanism. The approach is solid and aligns well with the codebase patterns. Issues Found: None Analysis:
Testing: No dedicated tests for SqlError, but the class is simple enough and implicitly tested through existing sql method tests in oauth2-mcp-client.test.ts. Consider adding explicit error case tests if SQL error handling becomes critical in production. The PR is ready to merge. |
27b965b to
377299b
Compare
377299b to
42ec18c
Compare
Allow users to override onSqlError(query, error) to customize logging behavior for SQL errors instead of using console.error directly. Fixes #767
42ec18c to
7b72e17
Compare
commit: |
Add documentation for the new onSqlError hook that allows users to customize SQL error logging behavior. This hook was added in cloudflare/agents#768 to replace hardcoded console.error calls. - Add onSqlError to the main Agent class API example - Add dedicated SQL error handling section with API signature - Include practical example showing integration with observability service - Explain when the hook is called and default behavior 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Adds documentation for the new onSqlError hook that allows users to customize SQL error logging behavior. The hook is called when SQL queries fail, giving users full control over error handling and logging. Related to cloudflare/agents#768 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Document the new onSqlError hook that allows users to customize SQL error logging behavior. This hook provides: - Ability to override the default console.error logging - Access to both the failed query and error details - Use cases for integrating with monitoring services Related PR: cloudflare/agents#768 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
| // Execute the SQL query with the provided values | ||
| return [...this.ctx.storage.sql.exec(query, ...values)] as T[]; | ||
| } catch (e) { | ||
| console.error(`failed to execute sql query: ${query}`, e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead why don't we use our logger directly here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or pipe into onError
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree with piping, done that
Address review feedback by piping SQL errors through onError with a SqlError class that preserves query context, rather than adding a separate onSqlError hook. - Add SqlError class with query and cause properties - Update sql() catch block to throw onError(new SqlError(query, e)) - Remove onSqlError method Users can now handle SQL errors in onError by checking instanceof SqlError.
Add documentation for the new onSqlError hook that allows developers to customize SQL error logging behavior in Agents. The hook is called before errors are thrown via onError, enabling custom logging, monitoring, or observability integrations. Changes: - Added onSqlError method signature to Agent class API reference - Included practical example showing custom error logging with context - Documented that errors are still thrown via onError after this hook Related PR: cloudflare/agents#768 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Document the new SqlError class that provides detailed information about failed SQL queries. This change syncs documentation for PR #768 which introduces SqlError for better error handling in the agents SDK. Changes: - Add SqlError section in API reference with properties and usage example - Add SQL Error Handling subsection under this.sql in agent-class.mdx - Update onError section to demonstrate SqlError handling - Add cross-references between related documentation sections Related: cloudflare/agents#768 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Add documentation for the new SqlError class that is thrown when SQL queries fail in Agents. This helps developers understand how to handle SQL-specific errors through the onError method. Related to cloudflare/agents#768 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
threepointone
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
approving pending CI
Instead of adding a separate onSqlError hook, I implemented a cleaner approach (suggested by @threepointone) that pipes SQL errors into the existing onError method using a new SqlError class
Fixes #767