mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Make log warning about bad gnc_numeric print the actual error code.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@20281 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
4741dc2b42
commit
5f7e50efef
@ -1297,7 +1297,8 @@ PrintAmountInternal(char *buf, gnc_numeric val, const GNCPrintAmountInfo *info)
|
|||||||
|
|
||||||
if (gnc_numeric_check (val))
|
if (gnc_numeric_check (val))
|
||||||
{
|
{
|
||||||
PWARN ("Bad numeric.");
|
PWARN ("Bad numeric: %s.",
|
||||||
|
gnc_numeric_errorCode_to_string(gnc_numeric_check (val)));
|
||||||
*buf = '\0';
|
*buf = '\0';
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1335,7 +1336,8 @@ PrintAmountInternal(char *buf, gnc_numeric val, const GNCPrintAmountInfo *info)
|
|||||||
/* Yes, rounding up can cause overflow. Check for it. */
|
/* Yes, rounding up can cause overflow. Check for it. */
|
||||||
if (gnc_numeric_check(val))
|
if (gnc_numeric_check(val))
|
||||||
{
|
{
|
||||||
PWARN("Bad numeric from rounding.");
|
PWARN ("Bad numeric from rounding: %s.",
|
||||||
|
gnc_numeric_errorCode_to_string(gnc_numeric_check (val)));
|
||||||
*buf = '\0';
|
*buf = '\0';
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1346,7 +1348,8 @@ PrintAmountInternal(char *buf, gnc_numeric val, const GNCPrintAmountInfo *info)
|
|||||||
val = gnc_numeric_sub (val, whole, GNC_DENOM_AUTO, GNC_HOW_RND_NEVER);
|
val = gnc_numeric_sub (val, whole, GNC_DENOM_AUTO, GNC_HOW_RND_NEVER);
|
||||||
if (gnc_numeric_check (val))
|
if (gnc_numeric_check (val))
|
||||||
{
|
{
|
||||||
PWARN ("Problem with remainder.");
|
PWARN ("Problem with remainder: %s.",
|
||||||
|
gnc_numeric_errorCode_to_string(gnc_numeric_check (val)));
|
||||||
*buf = '\0';
|
*buf = '\0';
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1507,4 +1507,23 @@ main(int argc, char ** argv)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
const char* gnc_numeric_errorCode_to_string(GNCNumericErrorCode error_code)
|
||||||
|
{
|
||||||
|
switch (error_code)
|
||||||
|
{
|
||||||
|
case GNC_ERROR_OK:
|
||||||
|
return "GNC_ERROR_OK";
|
||||||
|
case GNC_ERROR_ARG:
|
||||||
|
return "GNC_ERROR_ARG";
|
||||||
|
case GNC_ERROR_OVERFLOW:
|
||||||
|
return "GNC_ERROR_OVERFLOW";
|
||||||
|
case GNC_ERROR_DENOM_DIFF:
|
||||||
|
return "GNC_ERROR_DENOM_DIFF";
|
||||||
|
case GNC_ERROR_REMAINDER:
|
||||||
|
return "GNC_ERROR_REMAINDER";
|
||||||
|
default:
|
||||||
|
return "<unknown>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* ======================== END OF FILE =================== */
|
/* ======================== END OF FILE =================== */
|
||||||
|
@ -275,6 +275,10 @@ gboolean string_to_gnc_numeric(const gchar* str, gnc_numeric *n);
|
|||||||
* noted by error_code, rather than a number.
|
* noted by error_code, rather than a number.
|
||||||
*/
|
*/
|
||||||
gnc_numeric gnc_numeric_error(GNCNumericErrorCode error_code);
|
gnc_numeric gnc_numeric_error(GNCNumericErrorCode error_code);
|
||||||
|
|
||||||
|
/** Returns a string representation of the given GNCNumericErrorCode.
|
||||||
|
*/
|
||||||
|
const char* gnc_numeric_errorCode_to_string(GNCNumericErrorCode error_code);
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
/** @name Value Accessors
|
/** @name Value Accessors
|
||||||
|
Loading…
Reference in New Issue
Block a user