1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2024-12-14 10:13:05 +02:00

Add THROWP_* macro variants for error handling.

These macros allow an ErrorType pointer to be passed and are required for functions that may return different errors based on a parameter.
This commit is contained in:
David Steele 2018-04-23 10:24:04 -04:00
parent 18882cb882
commit 02cc8ccbd4
2 changed files with 15 additions and 0 deletions

View File

@ -69,6 +69,10 @@
<p>Add <code>bufEq</code> and <code>bufCat</code> to <code>Buffer</code> object.</p>
</release-item>
<release-item>
<p>Add <code>THROWP_</code>* macro variants for error handling. These macros allow an <code>ErrorType</code> pointer to be passed and are required for functions that may return different errors based on a parameter.</p>
</release-item>
<release-item>
<p>Split <code>cfgLoad()</code> into multiple functions to make testing easier. Mainly this helps with unit tests that need to do log expect testing.</p>
</release-item>

View File

@ -114,9 +114,13 @@ Throw an error
Errors can be thrown any time, but if there is no TRY block somewhere in the call stack then the program will exit and print the
error information to stderr.
The seldom used "THROWP" variants allow an error to be thrown with a pointer to the error type.
***********************************************************************************************************************************/
#define THROW(errorType, ...) \
errorInternalThrow(&errorType, __FILE__, __LINE__, __VA_ARGS__)
#define THROWP(errorType, ...) \
errorInternalThrow(errorType, __FILE__, __LINE__, __VA_ARGS__)
#define THROW_CODE(errorCode, ...) \
errorInternalThrow(errorTypeFromCode(errorCode), __FILE__, __LINE__, __VA_ARGS__)
@ -126,6 +130,13 @@ Throw an error when a system call fails
***********************************************************************************************************************************/
#define THROW_SYS_ERROR(errorType, ...) \
errorInternalThrowSys(errno, &errorType, __FILE__, __LINE__, __VA_ARGS__)
#define THROWP_SYS_ERROR(errorType, ...) \
errorInternalThrowSys(errno, errorType, __FILE__, __LINE__, __VA_ARGS__)
#define THROW_SYS_ERROR_CODE(errNo, errorType, ...) \
errorInternalThrowSys(errNo, &errorType, __FILE__, __LINE__, __VA_ARGS__)
#define THROWP_SYS_ERROR_CODE(errNo, errorType, ...) \
errorInternalThrowSys(errNo, errorType, __FILE__, __LINE__, __VA_ARGS__)
/***********************************************************************************************************************************
Rethrow the current error