From 97cefa927f4df44e7b9fd76d2d959cd5f23be545 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Tue, 30 Jun 2015 00:25:36 +0200 Subject: [PATCH] Class FString: improve floating point exception handling --- src/fstring.cpp | 2 +- test/fstring.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fstring.cpp b/src/fstring.cpp index b85d10ff..43b2a5e2 100644 --- a/src/fstring.cpp +++ b/src/fstring.cpp @@ -1027,7 +1027,7 @@ float FString::toFloat() const double d; d = this->toDouble(); - if ( d > FLT_MAX || d < FLT_MIN ) + if ( d > FLT_MAX || d < FLT_MIN ) throw std::overflow_error ("overflow"); return float(d); diff --git a/test/fstring.cpp b/test/fstring.cpp index 054bd79a..3b7bae88 100644 --- a/test/fstring.cpp +++ b/test/fstring.cpp @@ -126,9 +126,9 @@ int main (int, char**) { std::cerr << "Invalid argument: " << ex.what() << std::endl; } - catch (const std::out_of_range& ex) + catch (const std::exception& ex) { - std::cerr << "Out of range: " << ex.what() << std::endl; + std::cerr << "Arithmetic error: " << ex.what() << std::endl; } try