use pikotools Log::put_multiline() method when printing PostgreSQL error messages
This commit is contained in:
parent
0ce7578de3
commit
b32917afe7
|
@ -117,19 +117,15 @@ bool PostgreSQLConnector::do_query(const char * query_str, PostgreSQLQueryResult
|
|||
|
||||
if( !psql_result->psql_result || psql_result->psql_status == PGRES_FATAL_ERROR )
|
||||
{
|
||||
const char * err_msg = PQerrorMessage(pg_conn);
|
||||
|
||||
if( err_msg )
|
||||
{
|
||||
prepare_error_msg(err_msg, psql_result->error_msg);
|
||||
}
|
||||
|
||||
if( log )
|
||||
{
|
||||
const char * err_msg = PQerrorMessage(pg_conn);
|
||||
(*log) << pt::Log::log1 << "Morm: Problem with this query: \"" << query_str << '\"' << pt::Log::logend;
|
||||
|
||||
if( !psql_result->error_msg.empty() )
|
||||
(*log) << pt::Log::log1 << "Morm: " << psql_result->error_msg << pt::Log::logend;
|
||||
if( err_msg )
|
||||
{
|
||||
log->put_multiline("Morm: ", err_msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -174,7 +170,7 @@ const char * PostgreSQLConnector::query_last_sequence(const wchar_t * sequence_t
|
|||
if( log )
|
||||
{
|
||||
(*log) << pt::Log::log1 << "Morm: expected only one row in sequence result, has: " << psql_result.result_rows
|
||||
<< pt::Log::logend;
|
||||
<< pt::Log::logend;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -183,20 +179,12 @@ const char * PostgreSQLConnector::query_last_sequence(const wchar_t * sequence_t
|
|||
if( pg_conn && log )
|
||||
{
|
||||
const char * err_msg = PQerrorMessage(pg_conn);
|
||||
(*log) << pt::Log::log1 << "Morm: error (currval) for table: " << sequence_table_name << pt::Log::logend;
|
||||
|
||||
if( err_msg )
|
||||
{
|
||||
prepare_error_msg(err_msg, psql_result.error_msg);
|
||||
log->put_multiline("Morm: ", err_msg);
|
||||
}
|
||||
|
||||
(*log) << pt::Log::log1 << "Morm: error (currval) for table: " << sequence_table_name;
|
||||
|
||||
if( !psql_result.error_msg.empty() )
|
||||
{
|
||||
(*log) << ", " << psql_result.error_msg;
|
||||
}
|
||||
|
||||
(*log) << pt::Log::logend;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -304,18 +292,6 @@ bool PostgreSQLConnector::query_remove(const pt::TextStream & stream, QueryResul
|
|||
}
|
||||
|
||||
|
||||
void PostgreSQLConnector::prepare_error_msg(const char * msg_in, std::wstring & msg_out)
|
||||
{
|
||||
pt::utf8_to_wide(msg_in, msg_out);
|
||||
pt::trim_last_white(msg_out, true, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -158,7 +158,6 @@ protected:
|
|||
void unescape_bin_string(const char * str, std::string & out);
|
||||
void unescape_bin_string(const char * str, std::wstring & out);
|
||||
|
||||
void prepare_error_msg(const char * msg_in, std::wstring & msg_out);
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue