From 5fe021aa43a262e03659e09613301973ae378f88 Mon Sep 17 00:00:00 2001 From: Jochen Topf Date: Wed, 11 Nov 2020 18:22:22 +0100 Subject: [PATCH] Consistent error messages ending in . without newline And a few other minor formatting changes for error messages. --- src/flex-table-column.cpp | 6 +-- src/gazetteer-style.cpp | 8 ++-- src/geom-transform.cpp | 8 ++-- src/lua-utils.cpp | 4 +- src/node-persistent-cache.cpp | 2 +- src/node-ram-cache.cpp | 18 +++---- src/options.cpp | 34 ++++++------- src/output-flex.cpp | 90 ++++++++++++++++++----------------- src/output.cpp | 4 +- src/pgsql.cpp | 8 ++-- src/table.cpp | 4 +- src/taginfo.cpp | 13 ++--- src/tagtransform-lua.cpp | 10 ++-- src/tagtransform.cpp | 2 +- 14 files changed, 107 insertions(+), 104 deletions(-) diff --git a/src/flex-table-column.cpp b/src/flex-table-column.cpp index 191c20e81..7c32bd060 100644 --- a/src/flex-table-column.cpp +++ b/src/flex-table-column.cpp @@ -97,8 +97,8 @@ void flex_table_column_t::set_projection(char const *projection) m_srid = static_cast(std::strtoul(projection, &end, 10)); if (*end != '\0') { - throw std::runtime_error{std::string{"Unknown projection: "} + - projection}; + throw std::runtime_error{ + "Unknown projection: '{}'."_format(projection)}; } } @@ -144,7 +144,7 @@ std::string flex_table_column_t::sql_type_name() const case table_column_type::id_num: return "int8"; } - throw std::runtime_error{"Unknown column type"}; + throw std::runtime_error{"Unknown column type."}; } std::string flex_table_column_t::sql_modifiers() const diff --git a/src/gazetteer-style.cpp b/src/gazetteer-style.cpp index bc32992c3..cb1c0b311 100644 --- a/src/gazetteer-style.cpp +++ b/src/gazetteer-style.cpp @@ -192,7 +192,7 @@ void gazetteer_style_t::add_style_entry(std::string const &key, } if (!value.empty()) { throw std::runtime_error{ - "Style error. Prefix key can only be used with empty value.\n"}; + "Style error. Prefix key can only be used with empty value."}; } m_matcher.emplace_back(key.substr(0, key.size() - 1), flags, matcher_t::MT_PREFIX); @@ -203,7 +203,7 @@ void gazetteer_style_t::add_style_entry(std::string const &key, if (key[0] == '*') { if (!value.empty()) { throw std::runtime_error{ - "Style error. Suffix key can only be used with empty value.\n"}; + "Style error. Suffix key can only be used with empty value."}; } m_matcher.emplace_back(key.substr(1), flags, matcher_t::MT_SUFFIX); return; @@ -218,12 +218,12 @@ void gazetteer_style_t::add_style_entry(std::string const &key, if (add_metadata_style_entry(key)) { if (!value.empty()) { throw std::runtime_error{"Style error. Rules for OSM metadata " - "attributes must have an empty value.\n"}; + "attributes must have an empty value."}; } if (flags != SF_EXTRA) { throw std::runtime_error{"Style error. Rules for OSM metadata " "attributes must have the style flag " - "\"extra\" and no other flag.\n"}; + "\"extra\" and no other flag."}; } return; } diff --git a/src/geom-transform.cpp b/src/geom-transform.cpp index c0ff489d6..b9a8427ce 100644 --- a/src/geom-transform.cpp +++ b/src/geom-transform.cpp @@ -31,7 +31,7 @@ bool geom_transform_line_t::set_param(char const *name, lua_State *lua_state) if (lua_type(lua_state, -1) != LUA_TNUMBER) { throw std::runtime_error{ "The 'split_at' field in a geometry transformation " - "description must be a number"}; + "description must be a number."}; } m_split_at = lua_tonumber(lua_state, -1); @@ -75,7 +75,7 @@ bool geom_transform_area_t::set_param(char const *name, lua_State *lua_state) if (lua_type(lua_state, -1) != LUA_TBOOLEAN) { throw std::runtime_error{ "The 'multi' field in a geometry transformation " - "description must be a boolean"}; + "description must be a boolean."}; } m_multi = lua_toboolean(lua_state, -1); @@ -140,7 +140,7 @@ std::unique_ptr create_geom_transform(char const *type) } throw std::runtime_error{ - "Unknown geometry transformation '{}'"_format(type)}; + "Unknown geometry transformation '{}'."_format(type)}; } 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) char const *const field = lua_tostring(lua_state, -2); if (field == nullptr) { throw std::runtime_error{"All fields in geometry transformation " - "description must have string keys"}; + "description must have string keys."}; } if (std::strcmp(field, "create") != 0) { diff --git a/src/lua-utils.cpp b/src/lua-utils.cpp index aec3af517..d166b0a9e 100644 --- a/src/lua-utils.cpp +++ b/src/lua-utils.cpp @@ -111,7 +111,7 @@ char const *luaX_get_table_string(lua_State *lua_state, char const *key, lua_getfield(lua_state, table_index, key); if (!lua_isstring(lua_state, -1)) { throw std::runtime_error{ - "{} must contain a '{}' string field"_format(error_msg, key)}; + "{} must contain a '{}' string field."_format(error_msg, key)}; } return lua_tostring(lua_state, -1); } @@ -134,7 +134,7 @@ bool luaX_get_table_bool(lua_State *lua_state, char const *key, int table_index, } throw std::runtime_error{ - "{} must contain a '{}' boolean field"_format(error_msg, key)}; + "{} must contain a '{}' boolean field."_format(error_msg, key)}; } diff --git a/src/node-persistent-cache.cpp b/src/node-persistent-cache.cpp index 476412604..b917dcd38 100644 --- a/src/node-persistent-cache.cpp +++ b/src/node-persistent-cache.cpp @@ -59,7 +59,7 @@ node_persistent_cache::node_persistent_cache( if (m_fd < 0) { fmt::print(stderr, "Cannot open location cache file '{}': {}\n", m_fname, std::strerror(errno)); - throw std::runtime_error{"Unable to open flatnode file\n"}; + throw std::runtime_error{"Unable to open flatnode file."}; } m_index.reset(new index_t{m_fd}); diff --git a/src/node-ram-cache.cpp b/src/node-ram-cache.cpp index 11f82259b..fe6439495 100644 --- a/src/node-ram-cache.cpp +++ b/src/node-ram-cache.cpp @@ -95,7 +95,7 @@ void node_ram_cache::set_sparse(osmid_t id, osmium::Location location) } throw std::runtime_error{ "Node cache size is too small to fit all nodes. Please " - "increase cache size\n"}; + "increase cache size."}; } } maxSparseId = id; @@ -174,7 +174,7 @@ void node_ram_cache::set_dense(osmid_t id, osmium::Location location) blocks[block].reset_used(); blocks[block].block_offset = block; if (!blocks[block].nodes) { - throw std::runtime_error{"Error allocating nodes"}; + throw std::runtime_error{"Error allocating nodes."}; } queue[usedBlocks] = &blocks[block]; ++usedBlocks; @@ -190,7 +190,7 @@ void node_ram_cache::set_dense(osmid_t id, osmium::Location location) if ((allocStrategy & ALLOC_LOSSY) == 0) { throw std::runtime_error{ "Node cache size is too small to fit all nodes. " - "Please increase cache size"}; + "Please increase cache size."}; } /* We've reached the maximum number of blocks, so now we push the * 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) if (!blocks) { throw std::runtime_error{ "Out of memory for node cache dense index, try using " - "\"--cache-strategy sparse\" instead"}; + "\"--cache-strategy sparse\" instead."}; } queue = (ramNodeBlock **)calloc(maxBlocks, sizeof(ramNodeBlock *)); /* Use this method of allocation if virtual memory is limited, @@ -324,7 +324,7 @@ node_ram_cache::node_ram_cache(int strategy, int cacheSizeMB) fprintf(stderr, "Allocating dense node cache in block sized chunks\n"); if (!queue) { - throw std::runtime_error{"Out of memory, reduce --cache size"}; + throw std::runtime_error{"Out of memory, reduce --cache size."}; } } else { fprintf(stderr, "Allocating dense node cache in one big chunk\n"); @@ -332,7 +332,7 @@ node_ram_cache::node_ram_cache(int strategy, int cacheSizeMB) sizeof(osmium::Location)); if (!queue || !blockCache) { throw std::runtime_error{ - "Out of memory for dense node cache, reduce --cache size"}; + "Out of memory for dense node cache, reduce --cache size."}; } } } @@ -356,7 +356,7 @@ node_ram_cache::node_ram_cache(int strategy, int cacheSizeMB) } if (!sparseBlock) { throw std::runtime_error{ - "Out of memory for sparse node cache, reduce --cache size"}; + "Out of memory for sparse node cache, reduce --cache size."}; } } @@ -414,7 +414,7 @@ void node_ram_cache::set(osmid_t id, osmium::Location location) if ((id > 0 && id >> BLOCK_SHIFT >> 32U) || (id < 0 && ~id >> BLOCK_SHIFT >> 32U)) { throw std::runtime_error{"Absolute node IDs must not be larger than {}" - " (got {})"_format(1ULL << 42U, id)}; + " (got {})."_format(1ULL << 42U, id)}; } ++totalNodes; /* 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) // Command line options always have ALLOC_DENSE | ALLOC_SPARSE throw std::logic_error{ "Unexpected cache strategy in node_ram_cache::set with " - "allocStrategy {}"_format(allocStrategy)}; + "allocStrategy {}."_format(allocStrategy)}; } } diff --git a/src/options.cpp b/src/options.cpp index 7808e5cca..1331fd9ee 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -84,8 +84,8 @@ const struct option long_options[] = { void short_usage(char *arg0) { - throw std::runtime_error{"Usage error. For further information see:\n" - "\t{} -h|--help\n"_format(program_name(arg0))}; + throw std::runtime_error{"Usage error. For further information call:" + " {} --help"_format(program_name(arg0))}; } void long_usage(char const *arg0, bool verbose) @@ -332,17 +332,17 @@ static osmium::Box parse_bbox(char const *bbox) int const n = sscanf(bbox, "%lf,%lf,%lf,%lf", &minx, &miny, &maxx, &maxy); if (n != 4) { throw std::runtime_error{"Bounding box must be specified like: " - "minlon,minlat,maxlon,maxlat\n"}; + "minlon,minlat,maxlon,maxlat."}; } if (maxx <= minx) { throw std::runtime_error{ - "Bounding box failed due to maxlon <= minlon\n"}; + "Bounding box failed due to maxlon <= minlon."}; } if (maxy <= miny) { throw std::runtime_error{ - "Bounding box failed due to maxlat <= minlat\n"}; + "Bounding box failed due to maxlat <= minlat."}; } fmt::print(stderr, "Applying Bounding box: {},{} to {},{}\n", minx, miny, @@ -442,7 +442,7 @@ options_t::options_t(int argc, char *argv[]) : options_t() if (!optarg || optarg[0] == '-') { throw std::runtime_error{ "Missing argument for option --expire-tiles. Zoom " - "levels must be positive.\n"}; + "levels must be positive."}; } char *next_char; expire_tiles_zoom_min = @@ -451,7 +451,7 @@ options_t::options_t(int argc, char *argv[]) : options_t() throw std::runtime_error{ "Bad argument for option --expire-tiles. " "Minimum zoom level must be larger " - "than 0.\n"}; + "than 0."}; } // The first character after the number is ignored because that is the separating hyphen. if (*next_char == '-') { @@ -463,11 +463,11 @@ options_t::options_t(int argc, char *argv[]) : options_t() std::strtoul(next_char, &after_maxzoom, 10)); if (expire_tiles_zoom == 0 || *after_maxzoom != '\0') { throw std::runtime_error{"Invalid maximum zoom level " - "given for tile expiry.\n"}; + "given for tile expiry."}; } } else { throw std::runtime_error{ - "Invalid maximum zoom level given for tile expiry.\n"}; + "Invalid maximum zoom level given for tile expiry."}; } } else if (*next_char == '\0') { // end of string, no second zoom level given @@ -475,7 +475,7 @@ options_t::options_t(int argc, char *argv[]) : options_t() } else { throw std::runtime_error{"Minimum and maximum zoom level for " "tile expiry must be separated by " - "'-'.\n"}; + "'-'."}; } break; case 'o': @@ -498,7 +498,7 @@ options_t::options_t(int argc, char *argv[]) : options_t() case 'k': if (hstore_mode != hstore_column::none) { throw std::runtime_error{"You can not specify both --hstore " - "(-k) and --hstore-all (-j)\n"}; + "(-k) and --hstore-all (-j)."}; } hstore_mode = hstore_column::norm; break; @@ -508,7 +508,7 @@ options_t::options_t(int argc, char *argv[]) : options_t() case 'j': if (hstore_mode != hstore_column::none) { throw std::runtime_error{"You can not specify both --hstore " - "(-k) and --hstore-all (-j)\n"}; + "(-k) and --hstore-all (-j)."}; } hstore_mode = hstore_column::all; break; @@ -540,7 +540,7 @@ options_t::options_t(int argc, char *argv[]) : options_t() alloc_chunkwise = ALLOC_DENSE | ALLOC_SPARSE; } else { throw std::runtime_error{ - "Unrecognized cache strategy {}.\n"_format(optarg)}; + "Unrecognized cache strategy {}."_format(optarg)}; } break; case 205: @@ -627,15 +627,15 @@ void options_t::check_options() { if (append && create) { throw std::runtime_error{"--append and --create options can not be " - "used at the same time!\n"}; + "used at the same time!"}; } if (append && !slim) { - throw std::runtime_error{"--append can only be used with slim mode!\n"}; + throw std::runtime_error{"--append can only be used with slim mode!"}; } if (droptemp && !slim) { - throw std::runtime_error{"--drop only makes sense with --slim.\n"}; + throw std::runtime_error{"--drop only makes sense with --slim."}; } if (hstore_mode == hstore_column::none && hstore_columns.empty() && @@ -662,7 +662,7 @@ void options_t::check_options() if (cache == 0) { if (!slim) { throw std::runtime_error{ - "Ram node cache can only be disable in slim mode.\n"}; + "Ram node cache can only be disable in slim mode."}; } if (!flat_node_cache_enabled) { fprintf(stderr, "WARNING: ram cache is disabled. This will likely " diff --git a/src/output-flex.cpp b/src/output-flex.cpp index 2915e2dc7..1e4671cc5 100644 --- a/src/output-flex.cpp +++ b/src/output-flex.cpp @@ -86,7 +86,7 @@ prepared_lua_function_t::prepared_lua_function_t(lua_State *lua_state, return; } - throw std::runtime_error{"osm2pgsql.{} must be a function"_format(name)}; + throw std::runtime_error{"osm2pgsql.{} must be a function."_format(name)}; } static void push_osm_object_to_lua_stack(lua_State *lua_state, @@ -339,8 +339,9 @@ void output_flex_t::write_column( (column.type() == table_column_type::text)) { auto const *const str = lua_tolstring(lua_state(), -1, nullptr); if (!str) { - throw std::runtime_error{"Invalid type '{}' for text column"_format( - lua_typename(lua_state(), ltype))}; + throw std::runtime_error{ + "Invalid type '{}' for text column."_format( + lua_typename(lua_state(), ltype))}; } copy_mgr->add_column(str); } else if (column.type() == table_column_type::boolean) { @@ -357,7 +358,7 @@ void output_flex_t::write_column( break; default: throw std::runtime_error{ - "Invalid type '{}' for boolean column"_format( + "Invalid type '{}' for boolean column."_format( lua_typename(lua_state(), ltype))}; } } else if (column.type() == table_column_type::int2) { @@ -376,7 +377,7 @@ void output_flex_t::write_column( copy_mgr->add_column(lua_toboolean(lua_state(), -1)); } else { throw std::runtime_error{ - "Invalid type '{}' for int2 column"_format( + "Invalid type '{}' for int2 column."_format( lua_typename(lua_state(), ltype))}; } } else if (column.type() == table_column_type::int4) { @@ -395,7 +396,7 @@ void output_flex_t::write_column( copy_mgr->add_column(lua_toboolean(lua_state(), -1)); } else { throw std::runtime_error{ - "Invalid type '{}' for int4 column"_format( + "Invalid type '{}' for int4 column."_format( lua_typename(lua_state(), ltype))}; } } else if (column.type() == table_column_type::int8) { @@ -408,7 +409,7 @@ void output_flex_t::write_column( copy_mgr->add_column(lua_toboolean(lua_state(), -1)); } else { throw std::runtime_error{ - "Invalid type '{}' for int8 column"_format( + "Invalid type '{}' for int8 column."_format( lua_typename(lua_state(), ltype))}; } } else if (column.type() == table_column_type::real) { @@ -419,7 +420,7 @@ void output_flex_t::write_column( lua_tolstring(lua_state(), -1, nullptr)); } else { throw std::runtime_error{ - "Invalid type '{}' for real column"_format( + "Invalid type '{}' for real column."_format( lua_typename(lua_state(), ltype))}; } } else if (column.type() == table_column_type::hstore) { @@ -451,7 +452,7 @@ void output_flex_t::write_column( copy_mgr->finish_hash(); } else { throw std::runtime_error{ - "Invalid type '{}' for hstore column"_format( + "Invalid type '{}' for hstore column."_format( lua_typename(lua_state(), ltype))}; } } else if (column.type() == table_column_type::direction) { @@ -468,12 +469,12 @@ void output_flex_t::write_column( break; default: throw std::runtime_error{ - "Invalid type '{}' for direction column"_format( + "Invalid type '{}' for direction column."_format( lua_typename(lua_state(), ltype))}; } } else { throw std::runtime_error{ - "Column type {} not implemented"_format(column.type())}; + "Column type {} not implemented."_format(column.type())}; } lua_pop(lua_state(), 1); @@ -535,11 +536,11 @@ int output_flex_t::app_get_bbox() if (m_calling_context != calling_context::process_node && m_calling_context != calling_context::process_way) { throw std::runtime_error{"The function get_bbox() can only be called" - " from process_node() or process_way()"}; + " from process_node() or process_way()."}; } if (lua_gettop(lua_state()) > 1) { - throw std::runtime_error{"No parameter(s) needed for get_box()"}; + throw std::runtime_error{"No parameter(s) needed for get_box()."}; } if (m_context_node) { @@ -574,7 +575,7 @@ static void check_name(std::string const &name, char const *in) } throw std::runtime_error{ - "Special characters are not allowed in {} names: '{}'"_format(in, + "Special characters are not allowed in {} names: '{}'."_format(in, name)}; } @@ -591,7 +592,7 @@ flex_table_t &output_flex_t::create_flex_table() }); if (it != m_tables->cend()) { throw std::runtime_error{ - "Table with that name already exists: '{}'"_format(table_name)}; + "Table with name '{}' already exists."_format(table_name)}; } m_tables->emplace_back(table_name); @@ -662,11 +663,11 @@ void output_flex_t::setup_id_columns(flex_table_t *table) auto &column = table->add_column(column_name, "id_type"); column.set_not_null(); } else if (!lua_isnil(lua_state(), -1)) { - throw std::runtime_error{"type_column must be a string or nil"}; + throw std::runtime_error{"type_column must be a string or nil."}; } lua_pop(lua_state(), 1); // type_column } else { - throw std::runtime_error{"Unknown ids type: " + type}; + throw std::runtime_error{"Unknown ids type: {}."_format(type)}; } std::string const name = @@ -684,7 +685,7 @@ void output_flex_t::setup_flex_table_columns(flex_table_t *table) lua_getfield(lua_state(), -1, "columns"); if (lua_type(lua_state(), -1) != LUA_TTABLE) { throw std::runtime_error{ - "No columns defined for table '{}'"_format(table->name())}; + "No columns defined for table '{}'."_format(table->name())}; } std::size_t num_columns = 0; @@ -692,11 +693,11 @@ void output_flex_t::setup_flex_table_columns(flex_table_t *table) while (lua_next(lua_state(), -2) != 0) { if (!lua_isnumber(lua_state(), -2)) { throw std::runtime_error{ - "The 'columns' field must contain an array"}; + "The 'columns' field must contain an array."}; } if (!lua_istable(lua_state(), -1)) { throw std::runtime_error{ - "The entries in the 'columns' array must be tables"}; + "The entries in the 'columns' array must be tables."}; } char const *const type = @@ -720,7 +721,7 @@ void output_flex_t::setup_flex_table_columns(flex_table_t *table) column.set_projection(lua_tostring(lua_state(), -1)); } else { throw std::runtime_error{ - "Projection can only be set on geometry and area columns"}; + "Projection can only be set on geometry and area columns."}; } } @@ -731,15 +732,16 @@ void output_flex_t::setup_flex_table_columns(flex_table_t *table) if (num_columns == 0) { throw std::runtime_error{ - "No columns defined for table '{}'"_format(table->name())}; + "No columns defined for table '{}'."_format(table->name())}; } } int output_flex_t::app_define_table() { if (m_calling_context != calling_context::main) { - throw std::runtime_error{"Database tables have to be defined in the" - " main Lua code, not in any of the callbacks"}; + throw std::runtime_error{ + "Database tables have to be defined in the" + " main Lua code, not in any of the callbacks."}; } luaL_checktype(lua_state(), 1, LUA_TTABLE); @@ -763,13 +765,13 @@ static std::size_t table_idx_from_param(lua_State *lua_state) if (user_data == nullptr || !lua_getmetatable(lua_state, 1)) { throw std::runtime_error{ - "First parameter must be of type osm2pgsql.table"}; + "First parameter must be of type osm2pgsql.table."}; } luaL_getmetatable(lua_state, osm2pgsql_table_name); if (!lua_rawequal(lua_state, -1, -2)) { throw std::runtime_error{ - "First parameter must be of type osm2pgsql.table"}; + "First parameter must be of type osm2pgsql.table."}; } lua_pop(lua_state, 2); @@ -782,7 +784,7 @@ flex_table_t const &output_flex_t::get_table_from_param() { if (lua_gettop(lua_state()) != 1) { throw std::runtime_error{ - "Need exactly one parameter of type osm2pgsql.table"}; + "Need exactly one parameter of type osm2pgsql.table."}; } auto const &table = m_tables->at(table_idx_from_param(lua_state())); @@ -811,7 +813,7 @@ int output_flex_t::table_add_row() m_calling_context != calling_context::process_relation) { throw std::runtime_error{ "The function add_row() can only be called from the " - "process_node/way/relation() functions"}; + "process_node/way/relation() functions."}; } // Params are the table object and an optional Lua table with the contents @@ -819,7 +821,7 @@ int output_flex_t::table_add_row() auto const num_params = lua_gettop(lua_state()); if (num_params < 1 || num_params > 2) { throw std::runtime_error{ - "Need two parameters: The osm2pgsql.table and the row data"}; + "Need two parameters: The osm2pgsql.table and the row data."}; } auto &table_connection = @@ -835,19 +837,19 @@ int output_flex_t::table_add_row() if (m_context_node) { if (!table.matches_type(osmium::item_type::node)) { throw std::runtime_error{ - "Trying to add node to table '{}'"_format(table.name())}; + "Trying to add node to table '{}'."_format(table.name())}; } add_row(&table_connection, *m_context_node); } else if (m_context_way) { if (!table.matches_type(osmium::item_type::way)) { throw std::runtime_error{ - "Trying to add way to table '{}'"_format(table.name())}; + "Trying to add way to table '{}'."_format(table.name())}; } add_row(&table_connection, *m_context_way); } else if (m_context_relation) { if (!table.matches_type(osmium::item_type::relation)) { throw std::runtime_error{ - "Trying to add relation to table '{}'"_format(table.name())}; + "Trying to add relation to table '{}'."_format(table.name())}; } add_row(&table_connection, *m_context_relation); } @@ -913,7 +915,7 @@ get_transform(lua_State *lua_state, flex_table_column_t const &column) char const *create_type = lua_tostring(lua_state, -1); if (create_type == nullptr) { throw std::runtime_error{ - "Missing geometry transformation for column '{}'"_format( + "Missing geometry transformation for column '{}'."_format( column.name())}; } @@ -923,7 +925,7 @@ get_transform(lua_State *lua_state, flex_table_column_t const &column) if (!transform->is_compatible_with(column.type())) { throw std::runtime_error{ "Geometry transformation is not compatible " - "with column type '{}'"_format(column.type_name())}; + "with column type '{}'."_format(column.type_name())}; } lua_pop(lua_state, 1); // geom field @@ -958,7 +960,7 @@ get_default_transform(flex_table_column_t const &column, } throw std::runtime_error{ - "Missing geometry transformation for column '{}'"_format( + "Missing geometry transformation for column '{}'."_format( column.name())}; } @@ -1020,7 +1022,7 @@ void output_flex_t::add_row(table_connection_t *table_connection, // must be present. if (lua_gettop(lua_state()) == 0) { throw std::runtime_error{ - "Need two parameters: The osm2pgsql.table and the row data"}; + "Need two parameters: The osm2pgsql.table and the row data."}; } auto const geom_transform = get_transform(lua_state(), table.geom_column()); @@ -1055,7 +1057,7 @@ void output_flex_t::call_lua_function(prepared_lua_function_t func, if (luaX_pcall(lua_state(), 1, func.nresults())) { throw std::runtime_error{ "Failed to execute Lua function 'osm2pgsql.{}':" - " {}"_format(func.name(), lua_tostring(lua_state(), -1))}; + " {}."_format(func.name(), lua_tostring(lua_state(), -1))}; } m_calling_context = calling_context::main; @@ -1110,7 +1112,7 @@ void output_flex_t::select_relation_members(osmium::Relation const &relation) if (lua_type(lua_state(), -1) != LUA_TTABLE) { throw std::runtime_error{"select_relation_members() returned something " - "other than nil or a table"}; + "other than nil or a table."}; } // We have established that we have a table. Get the 'ways' field... @@ -1126,7 +1128,7 @@ void output_flex_t::select_relation_members(osmium::Relation const &relation) if (ltype != LUA_TTABLE) { throw std::runtime_error{ "Table returned from select_relation_members() contains 'ways' " - "field, but it isn't an array table"}; + "field, but it isn't an array table."}; } // Iterate over the 'ways' table to get all ids... @@ -1135,7 +1137,7 @@ void output_flex_t::select_relation_members(osmium::Relation const &relation) if (!lua_isnumber(lua_state(), -2)) { throw std::runtime_error{ "Table returned from select_relation_members() contains 'ways' " - "field, but it isn't an array table"}; + "field, but it isn't an array table."}; } osmid_t const id = lua_tointeger(lua_state(), -1); @@ -1143,7 +1145,7 @@ void output_flex_t::select_relation_members(osmium::Relation const &relation) throw std::runtime_error{ "Table returned from select_relation_members() contains 'ways' " "field, which must contain an array of non-zero integer way " - "ids"}; + "ids."}; } m_stage2_way_ids->set(id); @@ -1419,7 +1421,7 @@ void output_flex_t::init_lua(std::string const &filename) // Define "osmpgsql.table" metatable if (luaL_newmetatable(lua_state(), osm2pgsql_table_name) != 1) { - throw std::runtime_error{"Internal error: Lua newmetatable failed"}; + throw std::runtime_error{"Internal error: Lua newmetatable failed."}; } lua_pushvalue(lua_state(), -1); lua_setfield(lua_state(), -2, "__index"); @@ -1435,7 +1437,7 @@ void output_flex_t::init_lua(std::string const &filename) // Load compiled in init.lua if (luaL_dostring(lua_state(), lua_init())) { - throw std::runtime_error{"Internal error in Lua setup: {}"_format( + throw std::runtime_error{"Internal error in Lua setup: {}."_format( lua_tostring(lua_state(), -1))}; } @@ -1457,7 +1459,7 @@ void output_flex_t::init_lua(std::string const &filename) // Load user config file luaX_set_context(lua_state(), this); if (luaL_dofile(lua_state(), filename.c_str())) { - throw std::runtime_error{"Error loading lua config: {}"_format( + throw std::runtime_error{"Error loading lua config: {}."_format( lua_tostring(lua_state(), -1))}; } diff --git a/src/output.cpp b/src/output.cpp index 3f5470fe6..ebd5f7325 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -145,8 +145,8 @@ parse_multi_config(std::shared_ptr const &mid, } catch (std::exception const &e) { throw std::runtime_error{ - "Unable to parse multi config file `{}': {}"_format(file_name, - e.what())}; + "Unable to parse multi config file `{}': {}."_format(file_name, + e.what())}; } return outputs; diff --git a/src/pgsql.cpp b/src/pgsql.cpp index 99d1ce9be..195e1460a 100644 --- a/src/pgsql.cpp +++ b/src/pgsql.cpp @@ -33,7 +33,7 @@ pg_result_t pg_conn_t::query(ExecStatusType expect, char const *sql) const if (PQresultStatus(res.get()) != expect) { fmt::print(stderr, "SQL command failed: {}\nFull query: {}\n", error_msg(), sql); - throw std::runtime_error{"Executing SQL"}; + throw std::runtime_error{"Executing SQL."}; } return res; } @@ -105,14 +105,14 @@ void pg_conn_t::end_copy(std::string const &context) const if (PQputCopyEnd(m_conn.get(), nullptr) != 1) { fmt::print(stderr, "COPY END for {} failed: {}\n", context, error_msg()); - throw std::runtime_error{"Ending COPY mode"}; + throw std::runtime_error{"Ending COPY mode."}; } pg_result_t const res{PQgetResult(m_conn.get())}; if (PQresultStatus(res.get()) != PGRES_COMMAND_OK) { fmt::print(stderr, "result COPY END for {} failed: {}\n", context, error_msg()); - throw std::runtime_error{"Ending COPY mode"}; + throw std::runtime_error{"Ending COPY mode."}; } } @@ -136,7 +136,7 @@ pg_conn_t::exec_prepared_internal(char const *stmt, int num_params, param_values[i] ? param_values[i] : ""); } } - throw std::runtime_error{"Executing prepared statement"}; + throw std::runtime_error{"Executing prepared statement."}; } return res; diff --git a/src/table.cpp b/src/table.cpp index 953664f6a..1356daf9e 100644 --- a/src/table.cpp +++ b/src/table.cpp @@ -29,7 +29,7 @@ table_t::table_t(std::string const &name, std::string const &type, // if we dont have any columns if (m_columns.empty() && m_hstore_mode != hstore_column::all) { throw std::runtime_error{ - "No columns provided for table {}"_format(name)}; + "No columns provided for table {}."_format(name)}; } generate_copy_column_list(); @@ -67,7 +67,7 @@ void table_t::start(std::string const &conninfo, std::string const &table_space) { if (m_sql_conn) { throw std::runtime_error{m_target->name + - " cannot start, its already started"}; + " cannot start, its already started."}; } m_conninfo = conninfo; diff --git a/src/taginfo.cpp b/src/taginfo.cpp index ed8eb9b76..e9c7704b5 100644 --- a/src/taginfo.cpp +++ b/src/taginfo.cpp @@ -94,7 +94,7 @@ bool read_style_file(std::string const &filename, export_list *exlist) FILE *const in = std::fopen(filename.c_str(), "rt"); if (!in) { - throw std::runtime_error{"Couldn't open style file '{}': {}"_format( + throw std::runtime_error{"Couldn't open style file '{}': {}."_format( filename, std::strerror(errno))}; } @@ -121,8 +121,8 @@ bool read_style_file(std::string const &filename, export_list *exlist) if (fields < 3) { std::fclose(in); throw std::runtime_error{ - "Error reading style file line {} (fields={})"_format(lineno, - fields)}; + "Error reading style file line {} (fields={})."_format(lineno, + fields)}; } //place to keep info about this tag @@ -145,7 +145,7 @@ bool read_style_file(std::string const &filename, export_list *exlist) (temp.name.find('*') != std::string::npos))) { std::fclose(in); throw std::runtime_error{ - "wildcard '{}' in non-delete style entry"_format(temp.name)}; + "Wildcard '{}' in non-delete style entry."_format(temp.name)}; } if ((temp.name == "way_area") && (temp.flags == FLAG_DELETE)) { @@ -170,7 +170,7 @@ bool read_style_file(std::string const &filename, export_list *exlist) if (!kept) { std::fclose(in); throw std::runtime_error{ - "Weird style line {}:{}"_format(filename, lineno)}; + "Weird style line {}:{}."_format(filename, lineno)}; } read_valid_column = true; @@ -179,7 +179,8 @@ bool read_style_file(std::string const &filename, export_list *exlist) if (std::ferror(in)) { int const err = errno; std::fclose(in); - throw std::runtime_error{"{}: {}"_format(filename, std::strerror(err))}; + throw std::runtime_error{ + "{}: {}."_format(filename, std::strerror(err))}; } std::fclose(in); diff --git a/src/tagtransform-lua.cpp b/src/tagtransform-lua.cpp index 7d6a08de1..339b87bee 100644 --- a/src/tagtransform-lua.cpp +++ b/src/tagtransform-lua.cpp @@ -28,7 +28,7 @@ void lua_tagtransform_t::open_style() luaL_openlibs(L); if (luaL_dofile(L, m_lua_file.c_str())) { throw std::runtime_error{ - "Lua tag transform style error: {}"_format(lua_tostring(L, -1))}; + "Lua tag transform style error: {}."_format(lua_tostring(L, -1))}; } check_lua_function_exists(m_node_func); @@ -52,7 +52,7 @@ void lua_tagtransform_t::check_lua_function_exists(std::string const &func_name) lua_getglobal(L, func_name.c_str()); if (!lua_isfunction(L, -1)) { throw std::runtime_error{ - "Tag transform style does not contain a function {}"_format( + "Tag transform style does not contain a function {}."_format( func_name)}; } lua_pop(L, 1); @@ -72,7 +72,7 @@ bool lua_tagtransform_t::filter_tags(osmium::OSMObject const &o, int *polygon, lua_getglobal(L, m_rel_func.c_str()); break; default: - throw std::runtime_error{"Unknown OSM type"}; + throw std::runtime_error{"Unknown OSM type."}; } lua_newtable(L); /* key value table */ @@ -100,7 +100,7 @@ bool lua_tagtransform_t::filter_tags(osmium::OSMObject const &o, int *polygon, if (lua_pcall(L, 2, (o.type() == osmium::item_type::way) ? 4 : 2, 0)) { /* lua function failed */ throw std::runtime_error{"Failed to execute lua function for basic tag " - "processing: {}"_format(lua_tostring(L, -1))}; + "processing: {}."_format(lua_tostring(L, -1))}; } if (o.type() == osmium::item_type::way) { @@ -187,7 +187,7 @@ bool lua_tagtransform_t::filter_rel_member_tags( /* lua function failed */ throw std::runtime_error{ "Failed to execute lua function for relation tag " - "processing: {}"_format(lua_tostring(L, -1))}; + "processing: {}."_format(lua_tostring(L, -1))}; } *roads = (int)lua_tointeger(L, -1); diff --git a/src/tagtransform.cpp b/src/tagtransform.cpp index c221264ad..90317c466 100644 --- a/src/tagtransform.cpp +++ b/src/tagtransform.cpp @@ -21,7 +21,7 @@ tagtransform_t::make_tagtransform(options_t const *options, #else throw std::runtime_error{"Error: Could not init lua tag transform, as " "lua support was not compiled into this " - "version"}; + "version."}; #endif }