@@ -132,33 +132,38 @@ namespace CsLib {
132
132
if (props.end () == itCount || props.end () == itRatio)
133
133
return ;
134
134
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
147
166
}
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 " ;
162
167
}
163
168
164
169
void writeScanProps (std::ostream &str, const TScanProps &props) {
@@ -382,12 +387,17 @@ void HtmlWriter::Private::writeLinkToDetails(const Defect &def) {
382
387
// no project ID
383
388
return ;
384
389
385
- const int projId = boost::lexical_cast<int >(it->second );
390
+ try {
391
+ const int projId = boost::lexical_cast<int >(it->second );
386
392
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
+ }
391
401
}
392
402
393
403
void HtmlWriter::Private::writeNewDefWarning (const Defect &def) {
0 commit comments