gnucash maint: Catch more exceptions in gnc_numeric_convert
John Ralls
jralls at code.gnucash.org
Fri Mar 12 16:48:22 EST 2021
Updated via https://github.com/Gnucash/gnucash/commit/8e418570 (commit)
from https://github.com/Gnucash/gnucash/commit/04d4038e (commit)
commit 8e418570141083956fb534165a2ec543754bc985
Author: John Ralls <jralls at ceridwen.us>
Date: Fri Mar 12 13:42:39 2021 -0800
Catch more exceptions in gnc_numeric_convert
To enable fixing https://bugs.gnucash.org/show_bug.cgi?id=798132.
diff --git a/libgnucash/engine/gnc-numeric.cpp b/libgnucash/engine/gnc-numeric.cpp
index 040845a31..b99cb8586 100644
--- a/libgnucash/engine/gnc-numeric.cpp
+++ b/libgnucash/engine/gnc-numeric.cpp
@@ -1004,6 +1004,10 @@ gnc_numeric_convert(gnc_numeric in, int64_t denom, int how)
{
return convert(GncNumeric(in), denom, how);
}
+ catch (const std::invalid_argument& err)
+ {
+ return gnc_numeric_error(GNC_ERROR_OVERFLOW);
+ }
catch (const std::overflow_error& err)
{
return gnc_numeric_error(GNC_ERROR_OVERFLOW);
@@ -1012,6 +1016,10 @@ gnc_numeric_convert(gnc_numeric in, int64_t denom, int how)
{
return gnc_numeric_error(GNC_ERROR_OVERFLOW);
}
+ catch (const std::domain_error& err)
+ {
+ return gnc_numeric_error(GNC_ERROR_REMAINDER);
+ }
}
Summary of changes:
libgnucash/engine/gnc-numeric.cpp | 8 ++++++++
1 file changed, 8 insertions(+)
More information about the gnucash-changes
mailing list