Permalink
Browse files

improve error messages for exceptions thrown in symbolizers during lo…

…ad_map - closes #1441
  • Loading branch information...
1 parent c053940 commit 03860b1728bba954912763d712f23f68ea9fc4fe Dane Springmeyer committed Aug 23, 2012
Showing with 14 additions and 15 deletions.
  1. +3 −4 src/config_error.cpp
  2. +11 −11 src/load_map.cpp
View
@@ -25,11 +25,10 @@ config_error::config_error(std::string const& what, unsigned line_number, std::s
char const* config_error::what() const throw()
{
std::stringstream s;
- s << file_;
- if (line_number_ > 0) s << " line " << line_number_;
- if (!node_name_.empty()) s << " in node "<< node_name_;
- if (line_number_ > 0 || !file_.empty()) s << ": ";
s << what_;
+ if (!node_name_.empty()) s << " in " << node_name_;
+ if (line_number_ > 0) s << " at line " << line_number_;
+ if (!file_.empty()) s << " of '" << file_ << "'";
msg_ = s.str(); //Avoid returning pointer to dead object
return msg_.c_str();
}
View
@@ -921,7 +921,7 @@ void map_parser::parse_point_symbolizer(rule & rule, xml_node const & sym)
}
catch (const config_error & ex)
{
- ex.append_context("in PointSymbolizer", sym);
+ ex.append_context(sym);
throw;
}
}
@@ -1029,7 +1029,7 @@ void map_parser::parse_markers_symbolizer(rule & rule, xml_node const& node)
}
catch (config_error const& ex)
{
- ex.append_context("in MarkersSymbolizer", node);
+ ex.append_context(node);
throw;
}
}
@@ -1068,7 +1068,7 @@ void map_parser::parse_line_pattern_symbolizer(rule & rule, xml_node const & sym
}
catch (const config_error & ex)
{
- ex.append_context("in LinePatternSymbolizer", sym);
+ ex.append_context(sym);
throw;
}
}
@@ -1126,7 +1126,7 @@ void map_parser::parse_polygon_pattern_symbolizer(rule & rule,
}
catch (const config_error & ex)
{
- ex.append_context("in PolygonPatternSymbolizer", sym);
+ ex.append_context(sym);
throw;
}
}
@@ -1155,7 +1155,7 @@ void map_parser::parse_text_symbolizer(rule & rule, xml_node const& sym)
}
catch (const config_error & ex)
{
- ex.append_context("in TextSymbolizer", sym);
+ ex.append_context(sym);
throw;
}
}
@@ -1260,7 +1260,7 @@ void map_parser::parse_shield_symbolizer(rule & rule, xml_node const& sym)
}
catch (const config_error & ex)
{
- ex.append_context("in ShieldSymbolizer", sym);
+ ex.append_context(sym);
throw;
}
}
@@ -1369,7 +1369,7 @@ void map_parser::parse_line_symbolizer(rule & rule, xml_node const & sym)
}
catch (const config_error & ex)
{
- ex.append_context("in LineSymbolizer", sym);
+ ex.append_context(sym);
throw;
}
}
@@ -1398,7 +1398,7 @@ void map_parser::parse_polygon_symbolizer(rule & rule, xml_node const & sym)
}
catch (const config_error & ex)
{
- ex.append_context("in PolygonSymbolizer", sym);
+ ex.append_context(sym);
throw;
}
}
@@ -1424,7 +1424,7 @@ void map_parser::parse_building_symbolizer(rule & rule, xml_node const & sym)
}
catch (const config_error & ex)
{
- ex.append_context("in BuildingSymbolizer", sym);
+ ex.append_context(sym);
throw;
}
}
@@ -1502,7 +1502,7 @@ void map_parser::parse_raster_symbolizer(rule & rule, xml_node const & sym)
}
catch (const config_error & ex)
{
- ex.append_context("in RasterSymbolizer", sym);
+ ex.append_context(sym);
throw;
}
}
@@ -1588,7 +1588,7 @@ void map_parser::parse_raster_colorizer(raster_colorizer_ptr const& rc,
}
catch (const config_error & ex)
{
- ex.append_context("in RasterColorizer", node);
+ ex.append_context(node);
throw;
}
}

0 comments on commit 03860b1

Please sign in to comment.