From b20ac16d08085708a8b132e170bef2790fa53c11 Mon Sep 17 00:00:00 2001 From: Robert Schulze Date: Sun, 26 Feb 2023 15:17:28 +0000 Subject: [PATCH] Slightly easier to read SyntaxExceptions E.g. exception text for input '2 ': - before: Syntax error: Not a valid integer: 2 - now: Syntax error: Not a valid integer: '2 ' --- base/poco/Foundation/src/NumberParser.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/base/poco/Foundation/src/NumberParser.cpp b/base/poco/Foundation/src/NumberParser.cpp index 4081f3b2663..8d32e1a722c 100644 --- a/base/poco/Foundation/src/NumberParser.cpp +++ b/base/poco/Foundation/src/NumberParser.cpp @@ -44,7 +44,7 @@ int NumberParser::parse(const std::string& s, char thSep) if (tryParse(s, result, thSep)) return result; else - throw SyntaxException("Not a valid integer", s); + throw SyntaxException("Not a valid integer", "'" + s + "'"); } @@ -60,7 +60,7 @@ unsigned NumberParser::parseUnsigned(const std::string& s, char thSep) if (tryParseUnsigned(s, result, thSep)) return result; else - throw SyntaxException("Not a valid unsigned integer", s); + throw SyntaxException("Not a valid unsigned integer", "'" + s + "'"); } @@ -76,7 +76,7 @@ unsigned NumberParser::parseHex(const std::string& s) if (tryParseHex(s, result)) return result; else - throw SyntaxException("Not a valid hexadecimal integer", s); + throw SyntaxException("Not a valid hexadecimal integer", "'" + s + "'"); } @@ -94,7 +94,7 @@ unsigned NumberParser::parseOct(const std::string& s) if (tryParseOct(s, result)) return result; else - throw SyntaxException("Not a valid hexadecimal integer", s); + throw SyntaxException("Not a valid hexadecimal integer", "'" + s + "'"); } @@ -112,7 +112,7 @@ Int64 NumberParser::parse64(const std::string& s, char thSep) if (tryParse64(s, result, thSep)) return result; else - throw SyntaxException("Not a valid integer", s); + throw SyntaxException("Not a valid integer", "'" + s + "'"); } @@ -128,7 +128,7 @@ UInt64 NumberParser::parseUnsigned64(const std::string& s, char thSep) if (tryParseUnsigned64(s, result, thSep)) return result; else - throw SyntaxException("Not a valid unsigned integer", s); + throw SyntaxException("Not a valid unsigned integer", "'" + s + "'"); } @@ -144,7 +144,7 @@ UInt64 NumberParser::parseHex64(const std::string& s) if (tryParseHex64(s, result)) return result; else - throw SyntaxException("Not a valid hexadecimal integer", s); + throw SyntaxException("Not a valid hexadecimal integer", "'" + s + "'"); } @@ -162,7 +162,7 @@ UInt64 NumberParser::parseOct64(const std::string& s) if (tryParseOct64(s, result)) return result; else - throw SyntaxException("Not a valid hexadecimal integer", s); + throw SyntaxException("Not a valid hexadecimal integer", "'" + s + "'"); } @@ -180,7 +180,7 @@ double NumberParser::parseFloat(const std::string& s, char decSep, char thSep) if (tryParseFloat(s, result, decSep, thSep)) return result; else - throw SyntaxException("Not a valid floating-point number", s); + throw SyntaxException("Not a valid floating-point number", "'" + s + "'"); } @@ -196,7 +196,7 @@ bool NumberParser::parseBool(const std::string& s) if (tryParseBool(s, result)) return result; else - throw SyntaxException("Not a valid bool number", s); + throw SyntaxException("Not a valid bool number", "'" + s + "'"); }