@@ -132,33 +132,38 @@ namespace CsLib {
132132 if (props.end () == itCount || props.end () == itRatio)
133133 return ;
134134
135- const int count = boost::lexical_cast<int >(itCount->second );
136- const int ratio = boost::lexical_cast<int >(itRatio->second );
137- if (ratio < parsingRatioThr)
138- str << " <p><b style='color: #FF0000;'>warning:</b> "
139- " low parsing ratio: " << ratio << " %</p>\n " ;
140-
141- itCount = props.find (" diffbase-cov-compilation-unit-count" );
142- itRatio = props.find (" diffbase-cov-compilation-unit-ratio" );
143- if (props.end () == itCount || props.end () == itRatio) {
144- // fallback to deprecated format produced by cov-mockbuild
145- itCount = props.find (" diffbase-compilation-unit-count" );
146- itRatio = props.find (" diffbase-compilation-unit-ratio" );
135+ try {
136+ const int count = boost::lexical_cast<int >(itCount->second );
137+ const int ratio = boost::lexical_cast<int >(itRatio->second );
138+ if (ratio < parsingRatioThr)
139+ str << " <p><b style='color: #FF0000;'>warning:</b> "
140+ " low parsing ratio: " << ratio << " %</p>\n " ;
141+
142+ itCount = props.find (" diffbase-cov-compilation-unit-count" );
143+ itRatio = props.find (" diffbase-cov-compilation-unit-ratio" );
144+ if (props.end () == itCount || props.end () == itRatio) {
145+ // fallback to deprecated format produced by cov-mockbuild
146+ itCount = props.find (" diffbase-compilation-unit-count" );
147+ itRatio = props.find (" diffbase-compilation-unit-ratio" );
148+ }
149+ if (props.end () == itCount || props.end () == itRatio)
150+ return ;
151+
152+ const int baseCount = boost::lexical_cast<int >(itCount->second );
153+ const int baseRatio = boost::lexical_cast<int >(itRatio->second );
154+ if (baseRatio < parsingRatioThr && baseRatio < ratio)
155+ str << " <p><b style='color: #FF0000;'>warning:</b> "
156+ " low parsing ratio in diff base: "
157+ << baseRatio << " %</p>\n " ;
158+
159+ if (!count || 100 * baseCount / count < parsingOldToNewRatioThr)
160+ str << " <p><b style='color: #FF0000;'>warning:</b> "
161+ " low count of parsed units in diff base: "
162+ << baseCount << " </p>\n " ;
163+ }
164+ catch (boost::bad_lexical_cast &) {
165+ // failed to parse count/ratio
147166 }
148- if (props.end () == itCount || props.end () == itRatio)
149- return ;
150-
151- const int baseCount = boost::lexical_cast<int >(itCount->second );
152- const int baseRatio = boost::lexical_cast<int >(itRatio->second );
153- if (baseRatio < parsingRatioThr && baseRatio < ratio)
154- str << " <p><b style='color: #FF0000;'>warning:</b> "
155- " low parsing ratio in diff base: "
156- << baseRatio << " %</p>\n " ;
157-
158- if (!count || 100 * baseCount / count < parsingOldToNewRatioThr)
159- str << " <p><b style='color: #FF0000;'>warning:</b> "
160- " low count of parsed units in diff base: "
161- << baseCount << " </p>\n " ;
162167 }
163168
164169 void writeScanProps (std::ostream &str, const TScanProps &props) {
@@ -382,12 +387,17 @@ void HtmlWriter::Private::writeLinkToDetails(const Defect &def) {
382387 // no project ID
383388 return ;
384389
385- const int projId = boost::lexical_cast<int >(it->second );
390+ try {
391+ const int projId = boost::lexical_cast<int >(it->second );
386392
387- // write the link
388- this ->str << " <a href ='"
389- << boost::format (this ->defUrlTemplate ) % projId % defId
390- << " '>[Show Details]</a>" ;
393+ // write the link
394+ this ->str << " <a href ='"
395+ << boost::format (this ->defUrlTemplate ) % projId % defId
396+ << " '>[Show Details]</a>" ;
397+ }
398+ catch (boost::bad_lexical_cast &) {
399+ // failed to parse project ID
400+ }
391401}
392402
393403void HtmlWriter::Private::writeNewDefWarning (const Defect &def) {
0 commit comments