fix: unusage throwError and onError property on createRouter() function#42
Merged
himself65 merged 6 commits intobetter-auth:mainfrom Sep 10, 2025
Merged
Conversation
…rror` property on RouterConfig
…ror` property on RouterConfig
…ter options on readme
1 task
Contributor
Author
|
Can I get any update on this PR? @himself65 @Bekacru etc. |
himself65
reviewed
Sep 9, 2025
Member
himself65
left a comment
There was a problem hiding this comment.
Thanks for letting me know. I will check later
himself65
approved these changes
Sep 10, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were made?
This PR fixes the usage of error handling when creating a router using createRouter() function:
onErrorbehaves when throwing new errors or returning voidthrowErrorsetting remains relevant even when onError is providedWhy were these changes made?
These documentation improvements address issues similar to those raised in better-auth/better-auth#2400, where users needed better ways to customize error messages. The updated documentation now clearly explains:
How onError can be used to customize error handling, including:
How throwError continues to be relevant even when onError is provided, specifically when:
These clarifications help users better understand the flexible error handling options available to them and make more informed decisions about error management in their applications.
Testing checklist
Related issues
Addresses documentation needs similar to those in better-auth/better-auth#2400 and Sentry is not capturing 500 errors inside Better Auth #3617
regarding error message customization.