Skip to content

Commit

Permalink
Change format for column names in exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
d-frey committed Apr 27, 2024
1 parent 85ed652 commit 93e3f74
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion include/tao/pq/row.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ namespace tao::pq
{
if( result_traits_size< T > != m_columns ) {
const auto type = internal::demangle< T >();
throw std::out_of_range( internal::printf( "datatype (%.*s) requires %zu columns, but row/slice has %zu columns", static_cast< int >( type.size() ), type.data(), result_traits_size< T >, m_columns ) );
throw std::out_of_range( internal::printf( "datatype '%.*s' requires %zu columns, but row/slice has %zu columns", static_cast< int >( type.size() ), type.data(), result_traits_size< T >, m_columns ) );
}
return get< T >( 0 );
}
Expand Down
2 changes: 1 addition & 1 deletion include/tao/pq/table_row.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ namespace tao::pq
{
if( result_traits_size< T > != m_columns ) {
const auto type = internal::demangle< T >();
throw std::out_of_range( internal::printf( "datatype (%.*s) requires %zu columns, but table_row/slice has %zu columns", static_cast< int >( type.size() ), type.data(), result_traits_size< T >, m_columns ) );
throw std::out_of_range( internal::printf( "datatype '%.*s' requires %zu columns, but table_row/slice has %zu columns", static_cast< int >( type.size() ), type.data(), result_traits_size< T >, m_columns ) );
}
return get< T >( 0 );
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib/pq/result.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ namespace tao::pq
if( column < 0 ) {
assert( column == -1 );
check_has_result_set();
throw std::out_of_range( "column not found: " + std::string( in_name ) );
throw std::out_of_range( "column '" + std::string( in_name ) + "' not found" );
}
return column;
}
Expand Down Expand Up @@ -122,7 +122,7 @@ namespace tao::pq
auto result::get( const std::size_t row, const std::size_t column ) const -> const char*
{
if( is_null( row, column ) ) {
throw std::runtime_error( internal::printf( "unexpected NULL value in row %zu column %zu = %s", row, column, name( column ).c_str() ) );
throw std::runtime_error( internal::printf( "unexpected NULL value in row %zu column %zu/'%s'", row, column, name( column ).c_str() ) );
}
return PQgetvalue( m_pgresult.get(), static_cast< int >( row ), static_cast< int >( column ) );
}
Expand Down

0 comments on commit 93e3f74

Please sign in to comment.