1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-15 01:04:37 +02:00

Improved error handling in build-code binary.

Show a full stack trace instead of just the error.
This commit is contained in:
David Steele
2023-03-06 21:07:08 +07:00
parent 0818601c05
commit 120a49b659

View File

@ -20,6 +20,19 @@ Code Builder
int
main(const int argListSize, const char *const argList[])
{
// Set stack trace and mem context error cleanup handlers
static const ErrorHandlerFunction errorHandlerList[] = {stackTraceClean, memContextClean};
errorHandlerSet(errorHandlerList, LENGTH_OF(errorHandlerList));
FUNCTION_LOG_BEGIN(logLevelDebug);
FUNCTION_LOG_PARAM(INT, argListSize);
FUNCTION_LOG_PARAM(CHARPY, argList);
FUNCTION_LOG_END();
int result = 0;
TRY_BEGIN()
{
// Check parameters
CHECK(ParamInvalidError, argListSize >= 2 && argListSize <= 4, "only one to three parameters allowed");
@ -79,6 +92,15 @@ main(const int argListSize, const char *const argList[])
// PostgreSQL
if (strEqZ(STRDEF("postgres"), argList[1]))
bldPgRender(storageBuild, bldPgParse(storageRepo));
}
CATCH_FATAL()
{
LOG_FMT(
errorTypeCode(&AssertError) ? logLevelAssert : logLevelError, errorCode(), "%s\n%s", errorMessage(), errorStackTrace());
return 0;
result = errorCode();
}
TRY_END();
FUNCTION_LOG_RETURN(INT, result);
}