Skip to content

Commit 5fe021a

Browse files
committed
Consistent error messages ending in . without newline
And a few other minor formatting changes for error messages.
1 parent 639a7d1 commit 5fe021a

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
@@ -84,8 +84,8 @@ const struct option long_options[] = {
8484

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

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

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

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

348348
fmt::print(stderr, "Applying Bounding box: {},{} to {},{}\n", minx, miny,
@@ -442,7 +442,7 @@ options_t::options_t(int argc, char *argv[]) : options_t()
442442
if (!optarg || optarg[0] == '-') {
443443
throw std::runtime_error{
444444
"Missing argument for option --expire-tiles. Zoom "
445-
"levels must be positive.\n"};
445+
"levels must be positive."};
446446
}
447447
char *next_char;
448448
expire_tiles_zoom_min =
@@ -451,7 +451,7 @@ options_t::options_t(int argc, char *argv[]) : options_t()
451451
throw std::runtime_error{
452452
"Bad argument for option --expire-tiles. "
453453
"Minimum zoom level must be larger "
454-
"than 0.\n"};
454+
"than 0."};
455455
}
456456
// The first character after the number is ignored because that is the separating hyphen.
457457
if (*next_char == '-') {
@@ -463,19 +463,19 @@ options_t::options_t(int argc, char *argv[]) : options_t()
463463
std::strtoul(next_char, &after_maxzoom, 10));
464464
if (expire_tiles_zoom == 0 || *after_maxzoom != '\0') {
465465
throw std::runtime_error{"Invalid maximum zoom level "
466-
"given for tile expiry.\n"};
466+
"given for tile expiry."};
467467
}
468468
} else {
469469
throw std::runtime_error{
470-
"Invalid maximum zoom level given for tile expiry.\n"};
470+
"Invalid maximum zoom level given for tile expiry."};
471471
}
472472
} else if (*next_char == '\0') {
473473
// end of string, no second zoom level given
474474
expire_tiles_zoom = expire_tiles_zoom_min;
475475
} else {
476476
throw std::runtime_error{"Minimum and maximum zoom level for "
477477
"tile expiry must be separated by "
478-
"'-'.\n"};
478+
"'-'."};
479479
}
480480
break;
481481
case 'o':
@@ -498,7 +498,7 @@ options_t::options_t(int argc, char *argv[]) : options_t()
498498
case 'k':
499499
if (hstore_mode != hstore_column::none) {
500500
throw std::runtime_error{"You can not specify both --hstore "
501-
"(-k) and --hstore-all (-j)\n"};
501+
"(-k) and --hstore-all (-j)."};
502502
}
503503
hstore_mode = hstore_column::norm;
504504
break;
@@ -508,7 +508,7 @@ options_t::options_t(int argc, char *argv[]) : options_t()
508508
case 'j':
509509
if (hstore_mode != hstore_column::none) {
510510
throw std::runtime_error{"You can not specify both --hstore "
511-
"(-k) and --hstore-all (-j)\n"};
511+
"(-k) and --hstore-all (-j)."};
512512
}
513513
hstore_mode = hstore_column::all;
514514
break;
@@ -540,7 +540,7 @@ options_t::options_t(int argc, char *argv[]) : options_t()
540540
alloc_chunkwise = ALLOC_DENSE | ALLOC_SPARSE;
541541
} else {
542542
throw std::runtime_error{
543-
"Unrecognized cache strategy {}.\n"_format(optarg)};
543+
"Unrecognized cache strategy {}."_format(optarg)};
544544
}
545545
break;
546546
case 205:
@@ -627,15 +627,15 @@ void options_t::check_options()
627627
{
628628
if (append && create) {
629629
throw std::runtime_error{"--append and --create options can not be "
630-
"used at the same time!\n"};
630+
"used at the same time!"};
631631
}
632632

633633
if (append && !slim) {
634-
throw std::runtime_error{"--append can only be used with slim mode!\n"};
634+
throw std::runtime_error{"--append can only be used with slim mode!"};
635635
}
636636

637637
if (droptemp && !slim) {
638-
throw std::runtime_error{"--drop only makes sense with --slim.\n"};
638+
throw std::runtime_error{"--drop only makes sense with --slim."};
639639
}
640640

641641
if (hstore_mode == hstore_column::none && hstore_columns.empty() &&
@@ -662,7 +662,7 @@ void options_t::check_options()
662662
if (cache == 0) {
663663
if (!slim) {
664664
throw std::runtime_error{
665-
"Ram node cache can only be disable in slim mode.\n"};
665+
"Ram node cache can only be disable in slim mode."};
666666
}
667667
if (!flat_node_cache_enabled) {
668668
fprintf(stderr, "WARNING: ram cache is disabled. This will likely "

0 commit comments

Comments
 (0)