r20281 - gnucash/trunk/src - Make log warning about bad gnc_numeric print the actual error code.
Christian Stimming
cstim at code.gnucash.org
Sat Feb 12 10:53:37 EST 2011
Author: cstim
Date: 2011-02-12 10:53:37 -0500 (Sat, 12 Feb 2011)
New Revision: 20281
Trac: http://svn.gnucash.org/trac/changeset/20281
Modified:
gnucash/trunk/src/app-utils/gnc-ui-util.c
gnucash/trunk/src/libqof/qof/gnc-numeric.c
gnucash/trunk/src/libqof/qof/gnc-numeric.h
Log:
Make log warning about bad gnc_numeric print the actual error code.
Modified: gnucash/trunk/src/app-utils/gnc-ui-util.c
===================================================================
--- gnucash/trunk/src/app-utils/gnc-ui-util.c 2011-02-12 15:43:26 UTC (rev 20280)
+++ gnucash/trunk/src/app-utils/gnc-ui-util.c 2011-02-12 15:53:37 UTC (rev 20281)
@@ -1297,7 +1297,8 @@
if (gnc_numeric_check (val))
{
- PWARN ("Bad numeric.");
+ PWARN ("Bad numeric: %s.",
+ gnc_numeric_errorCode_to_string(gnc_numeric_check (val)));
*buf = '\0';
return 0;
}
@@ -1335,7 +1336,8 @@
/* Yes, rounding up can cause overflow. Check for it. */
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';
return 0;
}
@@ -1346,7 +1348,8 @@
val = gnc_numeric_sub (val, whole, GNC_DENOM_AUTO, GNC_HOW_RND_NEVER);
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';
return 0;
}
Modified: gnucash/trunk/src/libqof/qof/gnc-numeric.c
===================================================================
--- gnucash/trunk/src/libqof/qof/gnc-numeric.c 2011-02-12 15:43:26 UTC (rev 20280)
+++ gnucash/trunk/src/libqof/qof/gnc-numeric.c 2011-02-12 15:53:37 UTC (rev 20281)
@@ -1507,4 +1507,23 @@
}
#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 =================== */
Modified: gnucash/trunk/src/libqof/qof/gnc-numeric.h
===================================================================
--- gnucash/trunk/src/libqof/qof/gnc-numeric.h 2011-02-12 15:43:26 UTC (rev 20280)
+++ gnucash/trunk/src/libqof/qof/gnc-numeric.h 2011-02-12 15:53:37 UTC (rev 20281)
@@ -275,6 +275,10 @@
* noted by error_code, rather than a number.
*/
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
More information about the gnucash-changes
mailing list