From fc16bcbfcae7dd444d5859d18796ac0da9102f60 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 14 Nov 2018 18:02:49 +0100 Subject: [PATCH] Replace Base::Exception with appropriate subclass --- src/Mod/Spreadsheet/App/Cell.cpp | 4 ++-- src/Mod/Spreadsheet/App/PropertySheet.cpp | 4 ++-- src/Mod/Spreadsheet/App/Sheet.cpp | 6 +++--- src/Mod/Spreadsheet/App/lex.ExpressionParser.c | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Mod/Spreadsheet/App/Cell.cpp b/src/Mod/Spreadsheet/App/Cell.cpp index 5bdfde67d3..4797bbaff2 100644 --- a/src/Mod/Spreadsheet/App/Cell.cpp +++ b/src/Mod/Spreadsheet/App/Cell.cpp @@ -371,7 +371,7 @@ void Cell::setDisplayUnit(const std::string &unit) boost::shared_ptr e(ExpressionParser::parseUnit(owner->sheet(), unit.c_str())); if (!e) - throw Base::Exception("Invalid unit"); + throw Base::UnitsMismatchError("Invalid unit"); newDisplayUnit = DisplayUnit(unit, e->getUnit(), e->getScaler()); } @@ -713,7 +713,7 @@ int Cell::decodeAlignment(const std::string & itemStr, int alignment) else if (itemStr == "bottom") alignment = (alignment & ~Cell::ALIGNMENT_VERTICAL) | Cell::ALIGNMENT_BOTTOM; else - throw Base::Exception("Invalid alignment."); + throw Base::ValueError("Invalid alignment."); return alignment; } diff --git a/src/Mod/Spreadsheet/App/PropertySheet.cpp b/src/Mod/Spreadsheet/App/PropertySheet.cpp index 1006f80e89..4a9d5c9ae0 100644 --- a/src/Mod/Spreadsheet/App/PropertySheet.cpp +++ b/src/Mod/Spreadsheet/App/PropertySheet.cpp @@ -456,13 +456,13 @@ void PropertySheet::setDisplayUnit(CellAddress address, const std::string &unit) void PropertySheet::setAlias(CellAddress address, const std::string &alias) { if (alias.size() > 0 && !isValidAlias(alias)) - throw Base::Exception("Invalid alias"); + throw Base::ValueError("Invalid alias"); const Cell * aliasedCell = getValueFromAlias(alias); Cell * cell = nonNullCellAt(address); if (aliasedCell != 0 && cell != aliasedCell) - throw Base::Exception("Alias already defined."); + throw Base::ValueError("Alias already defined."); assert(cell != 0); diff --git a/src/Mod/Spreadsheet/App/Sheet.cpp b/src/Mod/Spreadsheet/App/Sheet.cpp index 44f455050c..dec2b2a4b3 100644 --- a/src/Mod/Spreadsheet/App/Sheet.cpp +++ b/src/Mod/Spreadsheet/App/Sheet.cpp @@ -427,7 +427,7 @@ void Sheet::getCellAddress(const Property *prop, CellAddress & address) if (i != propAddress.end()) address = i->second; else - throw Base::Exception("Property is not a cell"); + throw Base::TypeError("Property is not a cell"); } /** @@ -1137,14 +1137,14 @@ void Sheet::setAlias(CellAddress address, const std::string &alias) if (existingAlias == address.toString()) // Same as old? return; else - throw Base::Exception("Alias already defined"); + throw Base::ValueError("Alias already defined"); } else if (alias.size() == 0) // Empty? cells.setAlias(address, ""); else if (isValidAlias(alias)) // Valid? cells.setAlias(address, alias); else - throw Base::Exception("Invalid alias"); + throw Base::ValueError("Invalid alias"); } /** diff --git a/src/Mod/Spreadsheet/App/lex.ExpressionParser.c b/src/Mod/Spreadsheet/App/lex.ExpressionParser.c index e1eb68db75..ec24920b87 100644 --- a/src/Mod/Spreadsheet/App/lex.ExpressionParser.c +++ b/src/Mod/Spreadsheet/App/lex.ExpressionParser.c @@ -6302,9 +6302,9 @@ YY_RULE_SETUP { yylval.ivalue = strtoll( ExpressionParsertext, NULL, 0 ); if (yylval.ivalue == LLONG_MIN) - throw Base::Exception("Integer underflow"); + throw Base::UnderflowError("Integer underflow"); else if (yylval.ivalue == LLONG_MAX) - throw Base::Exception("Integer overflow"); + throw Base::OverflowError("Integer overflow"); if (yylval.ivalue == 1) { yylval.fvalue = 1; return ONE; } else return INTEGER; } YY_BREAK