Skip to content
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

small fix to make sure an exception is raised in '_RcppCCTZ_getOffset… #35

Merged
merged 2 commits into from Mar 8, 2020

Conversation

@lsilvest
Copy link
Contributor

@lsilvest lsilvest commented Mar 8, 2020

…' when the specified timezone is not found

Otherwise is just falls back silently on UTC and in nanotime the user cannot know if for example there was a typo in the timezone he supplied.

Copy link
Owner

@eddelbuettel eddelbuettel left a comment

Nice. My preferred idiom these days is Rcpp::stop() (which thows) over thow.

Shall we change that to

Rcpp::stop("Cannot retrieve timezone '%s'", tzstr);

which also lists the bad timezone thanks to the tinyfmt library we have in there.

@eddelbuettel
Copy link
Owner

@eddelbuettel eddelbuettel commented Mar 8, 2020

Ok, I noticed that your master checkout was also listed as 'one commit ahead, one behind' (because my last commit was merging from you, one then needs a rebase in the repo the PR originated from).

So I rebased, and then applied one cleanup commit with Rcpp::stop() and a changelog entry. Have a look. Probably ready as is :) but I wait to hear from you.

(And yes, I first accidentally pushed it back to my repo in a new branch rather than yours. My bad. Also taken care of.)

@lsilvest
Copy link
Contributor Author

@lsilvest lsilvest commented Mar 8, 2020

Thanks! Will make sure to rebase next time!

The stop is fine in our case because that's what we end up doing in nanotime (actually to be precise we call forward_exception_to_r), but maybe the throw is a bit more flexible because this function is intended to be called at C++ level in another package and the other package might want to do something else than stop if the conversion fails, or might simply want a custom error message. I don't think it matters much though. We have a similar throw in the other two functions (_RcppCCTZ_convertToCivilSecond and _RcppCCTZ_convertToTimePoint) so we should probably align all three to either throw or stop...

@eddelbuettel
Copy link
Owner

@eddelbuettel eddelbuettel commented Mar 8, 2020

Yes, I use them interchangeably too. There is, as I recall, a bit of refined work in the stop() to unwind the stack and whatnot. So if and when we have Rcpp.h included, it may be preferable. But it is, as you say, a small point. Merging now...

@eddelbuettel eddelbuettel merged commit 25d5e28 into eddelbuettel:master Mar 8, 2020
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.