-
-
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
better error messages #184
Comments
Maybe you could try this idea in a pull request? |
@ggrothendieck is something like this what you imagined? I would welcome you to modify |
Yes, that looks good. The important part is to actually modify all points where such an error can occur to ensure that the expanded info is provided. |
Now that we have a better |
Sure. Do you think you may have spare cycles for that any time soon? |
As this sort of came up on SO today and its a bit problematic for beginners... I glanced at the To maintain using the same class template <typename T1>
inline void NORET not_compatible(const char* fmt, const T1& arg1) {
throw Rcpp::not_compatible( tfm::format(fmt, arg1 ).c_str() );
}
template <typename T1, typename T2>
inline void NORET not_compatible(const char* fmt, const T1& arg1, const T2& arg2) {
throw Rcpp::not_compatible( tfm::format(fmt, arg1, arg2 ).c_str() );
}
template <typename T1, typename T2, typename T3>
inline void NORET not_compatible(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3) {
throw Rcpp::not_compatible( tfm::format(fmt, arg1, arg2, arg3 ).c_str() );
}
... Label as "Enhancement" + "API"? |
@eddelbuettel @kevinushey Thoughts on this? I would like to hopefully roll something out before next week. |
I'm definitely on board for commits / PRs that improve the error messages reported by Rcpp. |
Sure. If it works in that case and doesn't create trouble otherwise... |
Proposal
Enable Parameter Support /
|
Exception Class | Current | Proposed | Rationale |
---|---|---|---|
no_such_slot |
SIMPLE |
EXCEPTION |
Provide the name of the slot being accessed. |
not_a_closure |
SIMPLE |
EXCEPTION |
Provide the object type |
index_out_of_bounds |
SIMPLE |
ADVANCED |
Provide the index requested that fell out of bounds alongside of the length of the vector. |
not_compatible |
EXCEPTION |
ADVANCED |
Provide the starting class and requested end class. |
Table Macro Use Key:
SIMPLE
=RCPP_SIMPLE_EXCEPTION_CLASS
EXCEPTION
=RCPP_EXCEPTION_CLASS
ADVANCED
=RCPP_ADVANCED_EXCEPTION_CLASS
(new mimicsstop()
/warning()
)
Note: The difference between SIMPLE
and EXCEPTION
is the ability to pass a std::string
to EXCEPTION
that can dynamically change output whereas SIMPLE
error codes are static.
Error Codes to Remove
The following error codes are not used (or are not detectable via grep
/ GitHub search):
no_such_field
reference_creation_class
: Not used in Reference.h
Misc List of Error Code Class Usage
Below is a list of the current exception classes in Source (via GitHub)
RCPP_SIMPLE_EXCEPTION_CLASS
not_a_matrix
index_out_of_bounds
parse_error
not_s4
not_reference
not_initialized
no_such_slot
no_such_field
not_a_closure
no_such_function
unevaluated_promise
RCPP_EXCEPTION_CLASS
By the way... I completely forgot to detail how the new exception message should be written. Per feedback in #667, the goal here will be to state the error like before (in a similar syntax) and then follow it up with additional diagnostic information in the form of For simplicity, here is a list of the original exception messages contrasted with the new exception messages:
Any thoughts would be welcome as I'd like to have this change ready to go after #674 is merged. |
Would you prefer it if I staged the exception message changes in two parts? e.g.
Or just do it all together? |
Two sounds like a reasonable split. "Bite-sized". Some folks of course swallow warthogs whole so it all depends... |
Any issue with the proposed table above? About to submit a PR. |
So the PR would change from messages on the left to messages on the right? Wow. Sounds useful. Worth a test too. PR away. |
There are a number of places where Rcpp can fail because
TYPEOF(x)
does not equalRTYPE
. Since both of these are known at the point that the error is given it would help if these were displayed, e.g. rather than just"some message"
use:std:string("some message TYPEOF(x): ") + CHAR(Rf_type2str(TYPEOF(x))) + " RTYPE: " + CHAR(Rf_type2str(RTYPE))
At least that will give some bit of clue as to what the problem might be.
Any other info that might be added to the error message to help locate the problem could be helpful too.
This applies to RcppEigen too.
The text was updated successfully, but these errors were encountered: