Uncaught exception fix

This commit is contained in:
Markus Gans 2017-09-20 06:25:53 +02:00
parent 4eef45b8f0
commit f5a5ba3528
1 changed files with 28 additions and 6 deletions

View File

@ -168,14 +168,36 @@ int main (int, char**)
std::cout << "stream out: " << stream_uint << std::endl; std::cout << "stream out: " << stream_uint << std::endl;
// ...to double // ...to double
double stream_double; try
FString("0.123456e+2") >> stream_double; {
std::cout << "stream out: " << stream_double << std::endl; double stream_double;
FString("0.123456e+2") >> stream_double;
std::cout << "stream out: " << stream_double << std::endl;
}
catch (const std::invalid_argument& ex)
{
std::cerr << "Invalid argument: " << ex.what() << std::endl;
}
catch (const std::exception& ex)
{
std::cerr << "Arithmetic error: " << ex.what() << std::endl;
}
// ...to float // ...to float
float stream_float; try
FString("0.123e-3") >> stream_float; {
std::cout << "stream out: " << stream_float << std::endl; float stream_float;
FString("0.123e-3") >> stream_float;
std::cout << "stream out: " << stream_float << std::endl;
}
catch (const std::invalid_argument& ex)
{
std::cerr << "Invalid argument: " << ex.what() << std::endl;
}
catch (const std::exception& ex)
{
std::cerr << "Arithmetic error: " << ex.what() << std::endl;
}
// Test: c-string output // Test: c-string output
printf (" c_str: \"%s\"\n", out.c_str()); printf (" c_str: \"%s\"\n", out.c_str());