You've already forked pgbackrest
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:
@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user