@@ -201,9 +201,8 @@ static void write_json_table(json_writer_t *writer, lua_State *lua_state,
201201 while (lua_next (lua_state, -2 ) != 0 ) {
202202 int const ltype_key = lua_type (lua_state, -2 );
203203 if (ltype_key != LUA_TSTRING) {
204- throw std::runtime_error{
205- " Incorrect data type '{}' as key." _format (
206- lua_typename (lua_state, ltype_key))};
204+ throw fmt_error (" Incorrect data type '{}' as key." ,
205+ lua_typename (lua_state, ltype_key));
207206 }
208207 char const *const key = lua_tostring (lua_state, -2 );
209208 writer->key (key);
@@ -260,9 +259,8 @@ static void write_json(json_writer_t *writer, lua_State *lua_state,
260259 write_json_table (writer, lua_state, tables);
261260 break ;
262261 default :
263- throw std::runtime_error{
264- " Invalid type '{}' for json/jsonb column." _format (
265- lua_typename (lua_state, ltype))};
262+ throw fmt_error (" Invalid type '{}' for json/jsonb column." ,
263+ lua_typename (lua_state, ltype));
266264 }
267265}
268266
@@ -323,9 +321,8 @@ void flex_write_column(lua_State *lua_state,
323321 if (column.type () == table_column_type::text) {
324322 auto const *const str = lua_tolstring (lua_state, -1 , nullptr );
325323 if (!str) {
326- throw std::runtime_error{
327- " Invalid type '{}' for text column." _format (
328- lua_typename (lua_state, ltype))};
324+ throw fmt_error (" Invalid type '{}' for text column." ,
325+ lua_typename (lua_state, ltype));
329326 }
330327 copy_mgr->add_column (str);
331328 } else if (column.type () == table_column_type::boolean) {
@@ -341,9 +338,8 @@ void flex_write_column(lua_State *lua_state,
341338 lua_tolstring (lua_state, -1 , nullptr ));
342339 break ;
343340 default :
344- throw std::runtime_error{
345- " Invalid type '{}' for boolean column." _format (
346- lua_typename (lua_state, ltype))};
341+ throw fmt_error (" Invalid type '{}' for boolean column." ,
342+ lua_typename (lua_state, ltype));
347343 }
348344 } else if (column.type () == table_column_type::int2) {
349345 if (ltype == LUA_TNUMBER) {
@@ -360,9 +356,8 @@ void flex_write_column(lua_State *lua_state,
360356 } else if (ltype == LUA_TBOOLEAN) {
361357 copy_mgr->add_column (lua_toboolean (lua_state, -1 ));
362358 } else {
363- throw std::runtime_error{
364- " Invalid type '{}' for int2 column." _format (
365- lua_typename (lua_state, ltype))};
359+ throw fmt_error (" Invalid type '{}' for int2 column." ,
360+ lua_typename (lua_state, ltype));
366361 }
367362 } else if (column.type () == table_column_type::int4) {
368363 if (ltype == LUA_TNUMBER) {
@@ -379,9 +374,8 @@ void flex_write_column(lua_State *lua_state,
379374 } else if (ltype == LUA_TBOOLEAN) {
380375 copy_mgr->add_column (lua_toboolean (lua_state, -1 ));
381376 } else {
382- throw std::runtime_error{
383- " Invalid type '{}' for int4 column." _format (
384- lua_typename (lua_state, ltype))};
377+ throw fmt_error (" Invalid type '{}' for int4 column." ,
378+ lua_typename (lua_state, ltype));
385379 }
386380 } else if (column.type () == table_column_type::int8) {
387381 if (ltype == LUA_TNUMBER) {
@@ -392,9 +386,8 @@ void flex_write_column(lua_State *lua_state,
392386 } else if (ltype == LUA_TBOOLEAN) {
393387 copy_mgr->add_column (lua_toboolean (lua_state, -1 ));
394388 } else {
395- throw std::runtime_error{
396- " Invalid type '{}' for int8 column." _format (
397- lua_typename (lua_state, ltype))};
389+ throw fmt_error (" Invalid type '{}' for int8 column." ,
390+ lua_typename (lua_state, ltype));
398391 }
399392 } else if (column.type () == table_column_type::real) {
400393 if (ltype == LUA_TNUMBER) {
@@ -403,9 +396,8 @@ void flex_write_column(lua_State *lua_state,
403396 write_double (copy_mgr, column,
404397 lua_tolstring (lua_state, -1 , nullptr ));
405398 } else {
406- throw std::runtime_error{
407- " Invalid type '{}' for real column." _format (
408- lua_typename (lua_state, ltype))};
399+ throw fmt_error (" Invalid type '{}' for real column." ,
400+ lua_typename (lua_state, ltype));
409401 }
410402 } else if (column.type () == table_column_type::hstore) {
411403 if (ltype == LUA_TTABLE) {
@@ -417,27 +409,26 @@ void flex_write_column(lua_State *lua_state,
417409 char const *const val = lua_tostring (lua_state, -1 );
418410 if (key == nullptr ) {
419411 int const ltype_key = lua_type (lua_state, -2 );
420- throw std::runtime_error{
412+ throw fmt_error (
421413 " NULL key for hstore. Possibly this is due to"
422- " an incorrect data type '{}' as key." _format (
423- lua_typename (lua_state, ltype_key))} ;
414+ " an incorrect data type '{}' as key." ,
415+ lua_typename (lua_state, ltype_key));
424416 }
425417 if (val == nullptr ) {
426418 int const ltype_value = lua_type (lua_state, -1 );
427- throw std::runtime_error{
419+ throw fmt_error (
428420 " NULL value for hstore. Possibly this is due to"
429- " an incorrect data type '{}' for key '{}'." _format (
430- lua_typename (lua_state, ltype_value), key)} ;
421+ " an incorrect data type '{}' for key '{}'." ,
422+ lua_typename (lua_state, ltype_value), key);
431423 }
432424 copy_mgr->add_hash_elem (key, val);
433425 lua_pop (lua_state, 1 );
434426 }
435427
436428 copy_mgr->finish_hash ();
437429 } else {
438- throw std::runtime_error{
439- " Invalid type '{}' for hstore column." _format (
440- lua_typename (lua_state, ltype))};
430+ throw fmt_error (" Invalid type '{}' for hstore column." ,
431+ lua_typename (lua_state, ltype));
441432 }
442433 } else if ((column.type () == table_column_type::json) ||
443434 (column.type () == table_column_type::jsonb)) {
@@ -458,9 +449,8 @@ void flex_write_column(lua_State *lua_state,
458449 lua_tolstring (lua_state, -1 , nullptr ));
459450 break ;
460451 default :
461- throw std::runtime_error{
462- " Invalid type '{}' for direction column." _format (
463- lua_typename (lua_state, ltype))};
452+ throw fmt_error (" Invalid type '{}' for direction column." ,
453+ lua_typename (lua_state, ltype));
464454 }
465455 } else if (column.is_geometry_column ()) {
466456 // If this is a geometry column, the Lua function 'insert()' was
@@ -471,10 +461,9 @@ void flex_write_column(lua_State *lua_state,
471461 if (geom && !geom->is_null ()) {
472462 auto const type = column.type ();
473463 if (!is_compatible (*geom, type)) {
474- throw std::runtime_error{
475- " Geometry data for geometry column '{}'"
476- " has the wrong type ({})." _format (
477- column.name (), geometry_type (*geom))};
464+ throw fmt_error (" Geometry data for geometry column '{}'"
465+ " has the wrong type ({})." ,
466+ column.name (), geometry_type (*geom));
478467 }
479468 bool const wrap_multi =
480469 (type == table_column_type::multipoint ||
@@ -494,9 +483,8 @@ void flex_write_column(lua_State *lua_state,
494483 write_null (copy_mgr, column);
495484 }
496485 } else {
497- throw std::runtime_error{
498- " Need geometry data for geometry column '{}'." _format (
499- column.name ())};
486+ throw fmt_error (" Need geometry data for geometry column '{}'." ,
487+ column.name ());
500488 }
501489 } else if (column.type () == table_column_type::area) {
502490 // If this is an area column, the Lua function 'insert()' was
@@ -505,8 +493,8 @@ void flex_write_column(lua_State *lua_state,
505493 throw std::runtime_error{" Column type 'area' not allowed with "
506494 " 'insert()'. Maybe use 'real'?" };
507495 } else {
508- throw std::runtime_error{ " Column type {} not implemented." _format (
509- static_cast <uint8_t >(column.type ()))} ;
496+ throw fmt_error ( " Column type {} not implemented." ,
497+ static_cast <uint8_t >(column.type ()));
510498 }
511499
512500 lua_pop (lua_state, 1 );
0 commit comments