Skip to content

Commit 96b95a0

Browse files
authored
Merge pull request #1319 from joto/fix-error-msg
Consistent error messages ending in . without newline
2 parents ded35d5 + 5fe021a commit 96b95a0

14 files changed

Lines changed: 107 additions & 104 deletions

src/flex-table-column.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ void flex_table_column_t::set_projection(char const *projection)
9797
m_srid = static_cast<int>(std::strtoul(projection, &end, 10));
9898

9999
if (*end != '\0') {
100-
throw std::runtime_error{std::string{"Unknown projection: "} +
101-
projection};
100+
throw std::runtime_error{
101+
"Unknown projection: '{}'."_format(projection)};
102102
}
103103
}
104104

@@ -144,7 +144,7 @@ std::string flex_table_column_t::sql_type_name() const
144144
case table_column_type::id_num:
145145
return "int8";
146146
}
147-
throw std::runtime_error{"Unknown column type"};
147+
throw std::runtime_error{"Unknown column type."};
148148
}
149149

150150
std::string flex_table_column_t::sql_modifiers() const

src/gazetteer-style.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ void gazetteer_style_t::add_style_entry(std::string const &key,
192192
}
193193
if (!value.empty()) {
194194
throw std::runtime_error{
195-
"Style error. Prefix key can only be used with empty value.\n"};
195+
"Style error. Prefix key can only be used with empty value."};
196196
}
197197
m_matcher.emplace_back(key.substr(0, key.size() - 1), flags,
198198
matcher_t::MT_PREFIX);
@@ -203,7 +203,7 @@ void gazetteer_style_t::add_style_entry(std::string const &key,
203203
if (key[0] == '*') {
204204
if (!value.empty()) {
205205
throw std::runtime_error{
206-
"Style error. Suffix key can only be used with empty value.\n"};
206+
"Style error. Suffix key can only be used with empty value."};
207207
}
208208
m_matcher.emplace_back(key.substr(1), flags, matcher_t::MT_SUFFIX);
209209
return;
@@ -218,12 +218,12 @@ void gazetteer_style_t::add_style_entry(std::string const &key,
218218
if (add_metadata_style_entry(key)) {
219219
if (!value.empty()) {
220220
throw std::runtime_error{"Style error. Rules for OSM metadata "
221-
"attributes must have an empty value.\n"};
221+
"attributes must have an empty value."};
222222
}
223223
if (flags != SF_EXTRA) {
224224
throw std::runtime_error{"Style error. Rules for OSM metadata "
225225
"attributes must have the style flag "
226-
"\"extra\" and no other flag.\n"};
226+
"\"extra\" and no other flag."};
227227
}
228228
return;
229229
}

src/geom-transform.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ bool geom_transform_line_t::set_param(char const *name, lua_State *lua_state)
3131
if (lua_type(lua_state, -1) != LUA_TNUMBER) {
3232
throw std::runtime_error{
3333
"The 'split_at' field in a geometry transformation "
34-
"description must be a number"};
34+
"description must be a number."};
3535
}
3636
m_split_at = lua_tonumber(lua_state, -1);
3737

@@ -75,7 +75,7 @@ bool geom_transform_area_t::set_param(char const *name, lua_State *lua_state)
7575
if (lua_type(lua_state, -1) != LUA_TBOOLEAN) {
7676
throw std::runtime_error{
7777
"The 'multi' field in a geometry transformation "
78-
"description must be a boolean"};
78+
"description must be a boolean."};
7979
}
8080
m_multi = lua_toboolean(lua_state, -1);
8181

@@ -140,7 +140,7 @@ std::unique_ptr<geom_transform_t> create_geom_transform(char const *type)
140140
}
141141

142142
throw std::runtime_error{
143-
"Unknown geometry transformation '{}'"_format(type)};
143+
"Unknown geometry transformation '{}'."_format(type)};
144144
}
145145

146146
void init_geom_transform(geom_transform_t *transform, lua_State *lua_state)
@@ -155,7 +155,7 @@ void init_geom_transform(geom_transform_t *transform, lua_State *lua_state)
155155
char const *const field = lua_tostring(lua_state, -2);
156156
if (field == nullptr) {
157157
throw std::runtime_error{"All fields in geometry transformation "
158-
"description must have string keys"};
158+
"description must have string keys."};
159159
}
160160

161161
if (std::strcmp(field, "create") != 0) {

src/lua-utils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ char const *luaX_get_table_string(lua_State *lua_state, char const *key,
111111
lua_getfield(lua_state, table_index, key);
112112
if (!lua_isstring(lua_state, -1)) {
113113
throw std::runtime_error{
114-
"{} must contain a '{}' string field"_format(error_msg, key)};
114+
"{} must contain a '{}' string field."_format(error_msg, key)};
115115
}
116116
return lua_tostring(lua_state, -1);
117117
}
@@ -134,7 +134,7 @@ bool luaX_get_table_bool(lua_State *lua_state, char const *key, int table_index,
134134
}
135135

136136
throw std::runtime_error{
137-
"{} must contain a '{}' boolean field"_format(error_msg, key)};
137+
"{} must contain a '{}' boolean field."_format(error_msg, key)};
138138
}
139139

140140

src/node-persistent-cache.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ node_persistent_cache::node_persistent_cache(
5959
if (m_fd < 0) {
6060
fmt::print(stderr, "Cannot open location cache file '{}': {}\n",
6161
m_fname, std::strerror(errno));
62-
throw std::runtime_error{"Unable to open flatnode file\n"};
62+
throw std::runtime_error{"Unable to open flatnode file."};
6363
}
6464

6565
m_index.reset(new index_t{m_fd});

src/node-ram-cache.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ void node_ram_cache::set_sparse(osmid_t id, osmium::Location location)
9595
}
9696
throw std::runtime_error{
9797
"Node cache size is too small to fit all nodes. Please "
98-
"increase cache size\n"};
98+
"increase cache size."};
9999
}
100100
}
101101
maxSparseId = id;
@@ -174,7 +174,7 @@ void node_ram_cache::set_dense(osmid_t id, osmium::Location location)
174174
blocks[block].reset_used();
175175
blocks[block].block_offset = block;
176176
if (!blocks[block].nodes) {
177-
throw std::runtime_error{"Error allocating nodes"};
177+
throw std::runtime_error{"Error allocating nodes."};
178178
}
179179
queue[usedBlocks] = &blocks[block];
180180
++usedBlocks;
@@ -190,7 +190,7 @@ void node_ram_cache::set_dense(osmid_t id, osmium::Location location)
190190
if ((allocStrategy & ALLOC_LOSSY) == 0) {
191191
throw std::runtime_error{
192192
"Node cache size is too small to fit all nodes. "
193-
"Please increase cache size"};
193+
"Please increase cache size."};
194194
}
195195
/* We've reached the maximum number of blocks, so now we push the
196196
* current head of the tree down to the right level to restore the
@@ -313,7 +313,7 @@ node_ram_cache::node_ram_cache(int strategy, int cacheSizeMB)
313313
if (!blocks) {
314314
throw std::runtime_error{
315315
"Out of memory for node cache dense index, try using "
316-
"\"--cache-strategy sparse\" instead"};
316+
"\"--cache-strategy sparse\" instead."};
317317
}
318318
queue = (ramNodeBlock **)calloc(maxBlocks, sizeof(ramNodeBlock *));
319319
/* Use this method of allocation if virtual memory is limited,
@@ -324,15 +324,15 @@ node_ram_cache::node_ram_cache(int strategy, int cacheSizeMB)
324324
fprintf(stderr,
325325
"Allocating dense node cache in block sized chunks\n");
326326
if (!queue) {
327-
throw std::runtime_error{"Out of memory, reduce --cache size"};
327+
throw std::runtime_error{"Out of memory, reduce --cache size."};
328328
}
329329
} else {
330330
fprintf(stderr, "Allocating dense node cache in one big chunk\n");
331331
blockCache = (char *)malloc((maxBlocks + 1024) * per_block() *
332332
sizeof(osmium::Location));
333333
if (!queue || !blockCache) {
334334
throw std::runtime_error{
335-
"Out of memory for dense node cache, reduce --cache size"};
335+
"Out of memory for dense node cache, reduce --cache size."};
336336
}
337337
}
338338
}
@@ -356,7 +356,7 @@ node_ram_cache::node_ram_cache(int strategy, int cacheSizeMB)
356356
}
357357
if (!sparseBlock) {
358358
throw std::runtime_error{
359-
"Out of memory for sparse node cache, reduce --cache size"};
359+
"Out of memory for sparse node cache, reduce --cache size."};
360360
}
361361
}
362362

@@ -414,7 +414,7 @@ void node_ram_cache::set(osmid_t id, osmium::Location location)
414414
if ((id > 0 && id >> BLOCK_SHIFT >> 32U) ||
415415
(id < 0 && ~id >> BLOCK_SHIFT >> 32U)) {
416416
throw std::runtime_error{"Absolute node IDs must not be larger than {}"
417-
" (got {})"_format(1ULL << 42U, id)};
417+
" (got {})."_format(1ULL << 42U, id)};
418418
}
419419
++totalNodes;
420420
/* if ALLOC_DENSE and ALLOC_SPARSE are set, send it through
@@ -429,7 +429,7 @@ void node_ram_cache::set(osmid_t id, osmium::Location location)
429429
// Command line options always have ALLOC_DENSE | ALLOC_SPARSE
430430
throw std::logic_error{
431431
"Unexpected cache strategy in node_ram_cache::set with "
432-
"allocStrategy {}"_format(allocStrategy)};
432+
"allocStrategy {}."_format(allocStrategy)};
433433
}
434434
}
435435

src/options.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ const struct option long_options[] = {
8585

8686
void short_usage(char *arg0)
8787
{
88-
throw std::runtime_error{"Usage error. For further information see:\n"
89-
"\t{} -h|--help\n"_format(program_name(arg0))};
88+
throw std::runtime_error{"Usage error. For further information call:"
89+
" {} --help"_format(program_name(arg0))};
9090
}
9191

9292
void long_usage(char const *arg0, bool verbose)
@@ -335,17 +335,17 @@ static osmium::Box parse_bbox(char const *bbox)
335335
int const n = sscanf(bbox, "%lf,%lf,%lf,%lf", &minx, &miny, &maxx, &maxy);
336336
if (n != 4) {
337337
throw std::runtime_error{"Bounding box must be specified like: "
338-
"minlon,minlat,maxlon,maxlat\n"};
338+
"minlon,minlat,maxlon,maxlat."};
339339
}
340340

341341
if (maxx <= minx) {
342342
throw std::runtime_error{
343-
"Bounding box failed due to maxlon <= minlon\n"};
343+
"Bounding box failed due to maxlon <= minlon."};
344344
}
345345

346346
if (maxy <= miny) {
347347
throw std::runtime_error{
348-
"Bounding box failed due to maxlat <= minlat\n"};
348+
"Bounding box failed due to maxlat <= minlat."};
349349
}
350350

351351
fmt::print(stderr, "Applying Bounding box: {},{} to {},{}\n", minx, miny,
@@ -445,7 +445,7 @@ options_t::options_t(int argc, char *argv[]) : options_t()
445445
if (!optarg || optarg[0] == '-') {
446446
throw std::runtime_error{
447447
"Missing argument for option --expire-tiles. Zoom "
448-
"levels must be positive.\n"};
448+
"levels must be positive."};
449449
}
450450
char *next_char;
451451
expire_tiles_zoom_min =
@@ -454,7 +454,7 @@ options_t::options_t(int argc, char *argv[]) : options_t()
454454
throw std::runtime_error{
455455
"Bad argument for option --expire-tiles. "
456456
"Minimum zoom level must be larger "
457-
"than 0.\n"};
457+
"than 0."};
458458
}
459459
// The first character after the number is ignored because that is the separating hyphen.
460460
if (*next_char == '-') {
@@ -466,19 +466,19 @@ options_t::options_t(int argc, char *argv[]) : options_t()
466466
std::strtoul(next_char, &after_maxzoom, 10));
467467
if (expire_tiles_zoom == 0 || *after_maxzoom != '\0') {
468468
throw std::runtime_error{"Invalid maximum zoom level "
469-
"given for tile expiry.\n"};
469+
"given for tile expiry."};
470470
}
471471
} else {
472472
throw std::runtime_error{
473-
"Invalid maximum zoom level given for tile expiry.\n"};
473+
"Invalid maximum zoom level given for tile expiry."};
474474
}
475475
} else if (*next_char == '\0') {
476476
// end of string, no second zoom level given
477477
expire_tiles_zoom = expire_tiles_zoom_min;
478478
} else {
479479
throw std::runtime_error{"Minimum and maximum zoom level for "
480480
"tile expiry must be separated by "
481-
"'-'.\n"};
481+
"'-'."};
482482
}
483483
break;
484484
case 'o':
@@ -501,7 +501,7 @@ options_t::options_t(int argc, char *argv[]) : options_t()
501501
case 'k':
502502
if (hstore_mode != hstore_column::none) {
503503
throw std::runtime_error{"You can not specify both --hstore "
504-
"(-k) and --hstore-all (-j)\n"};
504+
"(-k) and --hstore-all (-j)."};
505505
}
506506
hstore_mode = hstore_column::norm;
507507
break;
@@ -511,7 +511,7 @@ options_t::options_t(int argc, char *argv[]) : options_t()
511511
case 'j':
512512
if (hstore_mode != hstore_column::none) {
513513
throw std::runtime_error{"You can not specify both --hstore "
514-
"(-k) and --hstore-all (-j)\n"};
514+
"(-k) and --hstore-all (-j)."};
515515
}
516516
hstore_mode = hstore_column::all;
517517
break;
@@ -543,7 +543,7 @@ options_t::options_t(int argc, char *argv[]) : options_t()
543543
alloc_chunkwise = ALLOC_DENSE | ALLOC_SPARSE;
544544
} else {
545545
throw std::runtime_error{
546-
"Unrecognized cache strategy {}.\n"_format(optarg)};
546+
"Unrecognized cache strategy {}."_format(optarg)};
547547
}
548548
break;
549549
case 205:
@@ -641,15 +641,15 @@ void options_t::check_options()
641641
{
642642
if (append && create) {
643643
throw std::runtime_error{"--append and --create options can not be "
644-
"used at the same time!\n"};
644+
"used at the same time!"};
645645
}
646646

647647
if (append && !slim) {
648-
throw std::runtime_error{"--append can only be used with slim mode!\n"};
648+
throw std::runtime_error{"--append can only be used with slim mode!"};
649649
}
650650

651651
if (droptemp && !slim) {
652-
throw std::runtime_error{"--drop only makes sense with --slim.\n"};
652+
throw std::runtime_error{"--drop only makes sense with --slim."};
653653
}
654654

655655
if (hstore_mode == hstore_column::none && hstore_columns.empty() &&
@@ -676,7 +676,7 @@ void options_t::check_options()
676676
if (cache == 0) {
677677
if (!slim) {
678678
throw std::runtime_error{
679-
"Ram node cache can only be disable in slim mode.\n"};
679+
"Ram node cache can only be disable in slim mode."};
680680
}
681681
if (!flat_node_cache_enabled) {
682682
fprintf(stderr, "WARNING: ram cache is disabled. This will likely "

0 commit comments

Comments
 (0)