You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-05 00:28:52 +02:00
Add error type and message to CHECK() macro.
A CHECK() worked exactly like ASSERT() except that it was compiled into production code. However, over time many checks have been added that should not throw AssertError, which should be reserved for probable coding errors. Allow the error code to be specified so other error types can be thrown. Also add a human-readable message since many of these could be seen by users even when there is no coding error. Update coverage exceptions for CHECK() to match ASSERT() since all conditions will never be covered.
This commit is contained in:
@ -127,7 +127,7 @@ pgClientOpen(PgClient *this)
|
||||
FUNCTION_LOG_END();
|
||||
|
||||
ASSERT(this != NULL);
|
||||
CHECK(this->connection == NULL);
|
||||
CHECK(AssertError, this->connection == NULL, "invalid connection");
|
||||
|
||||
MEM_CONTEXT_TEMP_BEGIN()
|
||||
{
|
||||
@ -175,7 +175,7 @@ pgClientQuery(PgClient *this, const String *query)
|
||||
FUNCTION_LOG_END();
|
||||
|
||||
ASSERT(this != NULL);
|
||||
CHECK(this->connection != NULL);
|
||||
CHECK(AssertError, this->connection != NULL, "invalid connection");
|
||||
ASSERT(query != NULL);
|
||||
|
||||
VariantList *result = NULL;
|
||||
@ -319,8 +319,7 @@ pgClientQuery(PgClient *this, const String *query)
|
||||
// Free the result
|
||||
PQclear(pgResult);
|
||||
|
||||
// Need to get a NULL result to complete the request
|
||||
CHECK(PQgetResult(this->connection) == NULL);
|
||||
CHECK(ServiceError, PQgetResult(this->connection) == NULL, "NULL result required to complete request");
|
||||
}
|
||||
TRY_END();
|
||||
|
||||
|
Reference in New Issue
Block a user