-
Notifications
You must be signed in to change notification settings - Fork 6
Untracked: Rethrow UserErrors in exceptions #90
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
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.
Pull Request Overview
This PR updates exception handling in data merging/stacking operations to preserve UserError classes when re-throwing exceptions. The changes ensure that user-facing errors maintain their proper error type while preventing false positives in error monitoring systems.
- Refactored the
createExceptionHandlerfunction to detect and preserveUserErrortypes - Added import for
StopForUserErrorfrom the flipU package - Updated version number to reflect these changes
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| R/mergingandstackingutilities.R | Refactored exception handler to preserve UserError types and use appropriate error functions |
| DESCRIPTION | Incremented version number from 1.8.9 to 1.8.10 |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| condition.fun <- function(...) { | ||
| if (warn) { | ||
| warning(..., call. = FALSE) | ||
| } else if (inherits(e, "UserError")) { | ||
| StopForUserError(...) | ||
| } else { | ||
| stop(..., call. = FALSE) |
Copilot
AI
Oct 11, 2025
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.
The condition.fun closure captures the exception e from the outer scope, but this creates a dependency on the outer variable that may not be the intended behavior. When condition.fun is called with different messages, it still checks inherits(e, "UserError") based on the original exception, which may not match the current context where condition.fun is being invoked.
| condition.fun <- function(...) { | |
| if (warn) { | |
| warning(..., call. = FALSE) | |
| } else if (inherits(e, "UserError")) { | |
| StopForUserError(...) | |
| } else { | |
| stop(..., call. = FALSE) | |
| condition.fun <- function(msg) { | |
| if (warn) { | |
| warning(msg, call. = FALSE) | |
| } else { | |
| if (inherits(e, "UserError")) { | |
| StopForUserError(msg) | |
| } else { | |
| stop(msg, call. = FALSE) | |
| } |
| condition.fun <- function(...) { | ||
| if (warn) { | ||
| warning(..., call. = FALSE) | ||
| } else if (inherits(e, "UserError")) { | ||
| StopForUserError(...) | ||
| } else { | ||
| stop(..., call. = FALSE) | ||
| } | ||
| } |
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.
This is the actual change. Some minor differences below since the call. argument is already specified here.
JustinCCYap
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.
LGTM
Preserve UserError class when re-throwing exceptions in data merging/stacking operations, ensuring proper error handling and user-facing error messages and preventing stop conditions and generating false positives for unexpected errors in bugdup.