-
-
Notifications
You must be signed in to change notification settings - Fork 208
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
Improved exception messages (close #184) #677
Improved exception messages (close #184) #677
Conversation
@@ -29,7 +29,10 @@ namespace Rcpp { | |||
namespace internal { | |||
|
|||
template <typename T> T primitive_as(SEXP x) { | |||
if (::Rf_length(x) != 1) throw ::Rcpp::not_compatible("expecting a single value"); | |||
if (::Rf_length(x) != 1) { |
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.
Should this be changed to Rf_xlength()
?
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.
Good catch -- I believe it should be.
Codecov Report
@@ Coverage Diff @@
## master #677 +/- ##
==========================================
- Coverage 92.88% 89.82% -3.06%
==========================================
Files 65 66 +1
Lines 3303 3509 +206
==========================================
+ Hits 3068 3152 +84
- Misses 235 357 +122
Continue to review full report at Codecov.
|
LGTM! |
Update: Not quite half-way done in the reverse-depends check and looking good just like the others did. |
We got eight failures, which is up by two:
|
@krlmlr : What I got was for the (CRAN version of) dplyr:
Would it be possible to soften that test to accept either the old or the new string? |
This test seems to have changed completely in the dev version of dplyr. |
Ah. Silly me. Could have tested myself. Is there a tarball somewhere I should fetch? |
We're not creating tarballs automatically, sorry. Building from a clone works for me, but you'd also need the dev version of rlang. |
That's puts it a little outside my test framework. I'll merge this, maybe you can do me the favour of testing against the master branch of Rcpp one of these days. |
Sure. Note: I'm getting lots of |
All quiet here with |
Just ran it, tests break everywhere :-( We did just add strict checks of the wording of error messages. How do we avoid Rcpp prepending/appending stuff to our error messages? |
Did I miss a step for building Rcpp? |
I truncated that a little. No need to flood all our screens. I don't know and cannot know what you did. You probably used devtools; I don't. I upgrade the repo to current, built a tarball and installed that. Works for me. |
As for
I suggest to contract with @coatless who is the guilty party^Hunsung hero who improved our messages. Maybe he is motivated to help you update yours. |
The warnings above look very much like something we had recently but cleaned since. Is it all possible that you are not at a clean checkout of the master branch? |
@eddelbuettel: I addressed the RE: Exception message overide: Unfortunately @krlmlr, when I designed the new exceptions I tried to remove the appending of specific phrases in the file. Thus, the new I'm more than happy to spend some cycles correcting the unit tests in |
I got this -- just a matter of imposing |
I indeed have @coatless: I'd rather prefer full control over the error messages. Would that be very difficult to implement on top of your extensions, which I'm sure are useful in most other cases? Obligatory: xkcd: Workflow |
To clarify, you do have full control over the error messages being triggered by Furthermore, you gain even more control over exceptions that have been upgraded to using With this being said, the prior exception classes, Overall, these changes were made to improve the experience developers have while working with Rcpp. In particular, the need for such changes originated based on my experience observing students in courses that I've created running into difficulty understanding what these exception messages mean. Therefore, I'm more of a proponent of working to fix the unit tests within
|
One additional exception message change was added in: |
@coatless: Thanks I forgot that we are using R code to construct and throw most error messages, even those that are detected at the C++ level. This is for both simplicity and consistency. We could avoid throwing the messages from R and throw from C++, but I'd rather catch in C++ and re-throw, again for the same reasons. Please advise. |
Unless I am missing something, both halves of those broken eggs originate with you: you set up the message you write, you catch the message and in the testing framework very stringently compare them. As @coatless pointed out, we don't tend to change these things all that often, but for whatever reason he caught me at a weak moment and I let it pass. So for once you (at the downstream package using it) need to update the comparison texts you are getting. We are pretty serious about keeping APIs stable so this particular problem should not hit you again in the foreseeable future. |
@krlmlr I've opened up an issue ticket on tidyverse/dplyr#2702. |
@eddelbuettel: I'm throwing messages in R, called from C++ code. The R <- C++ <- R roundtrip now adds prefix+suffix to the messages, which is useful in most cases but not in our very peculiar situation. We'll be working on a way to avoid that. This looks feasible because we call back into R to generate the error message only at very few designated places, we only need a way to extract the original message without prefix+suffix from the exception. |
This is PR 3 of 3.
The objective of this PR is to upgrade existing exception messages that were identified in #184 as being candidates for dynamic information.
(PR 1 (#674) included the upstream refresh of the tinyformat library. PR 2 (#676) put in place the exception infrastructure used in this build.)
Changes:
not_compatible()
tonot_a_matrix()
inMatrix.h
(one was missing athrow
!)