Exemplo n.º 1
0
static pgutErrorData *
pgut_errinit(int elevel)
{
	int save_errno = errno;
	pgutErrorData *edata = getErrorData();
	edata->elevel = elevel;
	edata->save_errno = save_errno;
	edata->ecode = (elevel >= ERROR ? 1 : 0);

	if (edata->msg.data)
		resetStringInfo(&edata->msg);
	else
		initStringInfo(&edata->msg);

	if (edata->detail.data)
		resetStringInfo(&edata->detail);
	else
		initStringInfo(&edata->detail);

	if (edata->hint.data)
		resetStringInfo(&edata->hint);
	else
		initStringInfo(&edata->hint);

	return edata;
}
Exemplo n.º 2
0
int
errcode(int errcode)
{
	pgutErrorData *edata = getErrorData();
	edata->ecode = errcode;
	return 0;
}
Exemplo n.º 3
0
int
errcode_errno(void)
{
	pgutErrorData  *edata = getErrorData();
	edata->code = edata->save_errno;
	return 0;
}
Exemplo n.º 4
0
int
errcode(int sqlerrcode)
{
	pgutErrorData  *edata = getErrorData();
	edata->code = sqlerrcode;
	return 0;
}
Exemplo n.º 5
0
void
pgut_errfinish(int dummy, ...)
{
	pgutErrorData  *edata = getErrorData();

	if (log_required(edata->elevel, pgut_log_level))
		pgut_error(edata->elevel, edata->code,
			edata->msg.data ? edata->msg.data : "unknown",
			edata->detail.data);

	if (pgut_abort_level <= edata->elevel && edata->elevel <= PANIC)
		exit_or_abort(edata->code);
}
Exemplo n.º 6
0
void
pgut_errfinish(int dummy, ...)
{
	pgutErrorData	*edata = getErrorData();

	if (edata->elevel >= pgut_log_level || debug)
		pgut_error(edata->elevel,
				edata->msg.data ? edata->msg.data : "unknown",
				edata->detail.data,
				edata->hint.data);

	if (pgut_abort_level <= edata->elevel && edata->elevel <= PANIC)
		exit_or_abort(edata->ecode);
}
Exemplo n.º 7
0
void
pgut_errfinish(int dummy, ...)
{
	pgutErrorData  *edata = getErrorData();

	if (log_required(edata->elevel, pgut_log_level))
		pgut_error(edata->elevel, edata->code,
			edata->msg.data ? edata->msg.data : "unknown",
			edata->detail.data);

	if (pgut_abort_level <= edata->elevel && edata->elevel <= PANIC)
	{
		in_cleanup = true; /* need to be set for cleaning temporary objects on error */
		exit_or_abort(edata->code, edata->elevel);
	}
}
Exemplo n.º 8
0
int
errhint(const char *fmt, ...)
{
	pgutErrorData	*edata = getErrorData();
	va_list			args;
	bool			ok;

	do
	{
		va_start(args, fmt);
		ok = appendStringInfoVA_c(&edata->hint, fmt, args);
		va_end(args);
	} while (!ok);
	trimStringBuffer(&edata->hint);

	return 0;	/* return value does not matter. */
}
Exemplo n.º 9
0
int
errmsg(const char *fmt, ...)
{
	pgutErrorData	*edata = getErrorData();
	va_list			args;
	size_t			len;
	bool			ok;

	do
	{
		va_start(args, fmt);
		ok = appendStringInfoVA_c(&edata->msg, fmt, args);
		va_end(args);
	} while (!ok);
	len = strlen(fmt);
	if ( len > 2 && strcmp(fmt + len -2, ": ") == 0)
		appendStringInfoString(&edata->msg, strerror(edata->save_errno));
	trimStringBuffer(&edata->msg);

	return 0;	/* return value does not matter. */
}