[Phylobase-commits] r806 - in pkg: R src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Aug 4 15:10:18 CEST 2010
Author: francois
Date: 2010-08-04 15:10:18 +0200 (Wed, 04 Aug 2010)
New Revision: 806
Modified:
pkg/R/readNCL.R
pkg/src/GetNCL.cpp
Log:
return NxsException messages to R without crashing
Modified: pkg/R/readNCL.R
===================================================================
--- pkg/R/readNCL.R 2010-07-28 19:25:48 UTC (rev 805)
+++ pkg/R/readNCL.R 2010-08-04 13:10:18 UTC (rev 806)
@@ -39,6 +39,11 @@
## $stateLabels: the labels for the states of the characters, i.e. the levels of the factors to be returned
## $dataChr: string that contains the data to be returned
ncl <- .Call("GetNCL", fileName, parameters, PACKAGE="phylobase")
+
+ ## Return Error message
+ if (length(ncl) == 1 && names(ncl) == "ErrorMsg") {
+ stop(ncl$ErrorMsg)
+ }
if (!quiet) print(ncl)
Modified: pkg/src/GetNCL.cpp
===================================================================
--- pkg/src/GetNCL.cpp 2010-07-28 19:25:48 UTC (rev 805)
+++ pkg/src/GetNCL.cpp 2010-08-04 13:10:18 UTC (rev 806)
@@ -83,6 +83,7 @@
std::vector<std::string> trees; //vector of Newick strings holding the names
std::vector<std::string> treeNames; //vector of tree names
std::vector<std::string> taxaNames; //vector of taxa names
+ std::string errorMsg; //error message
std::vector<bool> test(3);
test[0] = charall;
@@ -103,7 +104,14 @@
nexusReader.cullIdenticalTaxaBlocks(true);
/* End of making NCL less strict */
- nexusReader.ReadFilepath(const_cast < char* > (filename.c_str()), MultiFormatReader::NEXUS_FORMAT);
+ try {
+ nexusReader.ReadFilepath(const_cast < char* > (filename.c_str()), MultiFormatReader::NEXUS_FORMAT);
+ }
+ catch (NxsException &x) {
+ errorMsg = x.msg;
+ Rcpp::List res = Rcpp::List::create(Rcpp::Named("ErrorMsg") = errorMsg);
+ return res;
+ }
const unsigned nTaxaBlocks = nexusReader.GetNumTaxaBlocks();
for (unsigned t = 0; t < nTaxaBlocks; ++t) {
More information about the Phylobase-commits
mailing list