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:
@ -19,6 +19,19 @@ Code Builder
|
|||||||
|
|
||||||
int
|
int
|
||||||
main(const int argListSize, const char *const argList[])
|
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 parameters
|
||||||
CHECK(ParamInvalidError, argListSize >= 2 && argListSize <= 4, "only one to three parameters allowed");
|
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
|
// PostgreSQL
|
||||||
if (strEqZ(STRDEF("postgres"), argList[1]))
|
if (strEqZ(STRDEF("postgres"), argList[1]))
|
||||||
bldPgRender(storageBuild, bldPgParse(storageRepo));
|
bldPgRender(storageBuild, bldPgParse(storageRepo));
|
||||||
|
}
|
||||||
return 0;
|
CATCH_FATAL()
|
||||||
|
{
|
||||||
|
LOG_FMT(
|
||||||
|
errorTypeCode(&AssertError) ? logLevelAssert : logLevelError, errorCode(), "%s\n%s", errorMessage(), errorStackTrace());
|
||||||
|
|
||||||
|
result = errorCode();
|
||||||
|
}
|
||||||
|
TRY_END();
|
||||||
|
|
||||||
|
FUNCTION_LOG_RETURN(INT, result);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user