From 533ecbef9644b27f36204b1d5ea792b245af3137 Mon Sep 17 00:00:00 2001 From: Martchus Date: Thu, 14 Mar 2019 17:59:30 +0100 Subject: [PATCH] Adapt to c++utilities v5 --- CMakeLists.txt | 3 ++- main.cpp | 17 ++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 18b809a..23a4a01 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,8 @@ set(META_VERSION_PATCH 3) set(META_APP_VERSION ${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH}) # find c++utilities -find_package(c++utilities 4.10.0 REQUIRED) +set(CONFIGURATION_PACKAGE_SUFFIX "" CACHE STRING "sets the suffix for find_package() calls to packages configured via c++utilities") +find_package(c++utilities${CONFIGURATION_PACKAGE_SUFFIX} 5.0.0 REQUIRED) use_cpp_utilities() # include modules to apply configuration diff --git a/main.cpp b/main.cpp index c6741a3..5290001 100644 --- a/main.cpp +++ b/main.cpp @@ -5,8 +5,8 @@ #include #include +#include #include -#include #include #include @@ -214,8 +214,9 @@ vector locationsFromFile(const string &path) // prepare reading fstream file; file.open(path, ios_base::in); - if (!file) - IoUtilities::throwIoFailure(("Unable to open the file \"" + path + "\".").data()); + if (!file) { + throw std::ios_base::failure("Unable to open the file \"" % path + "\"."); + } file.exceptions(ios_base::badbit); string line; vector locations; @@ -270,9 +271,8 @@ void printTrackLength(const string &filePath, bool circle) vector locations(locationsFromFile(filePath)); printDistance(Location::trackLength(locations, circle)); cout << " (" << locations.size() << " trackpoints)"; - } catch (...) { - const char *what = ::IoUtilities::catchIoFailure(); - cout << "An IO failure occured when reading file from provided path: " << what << endl; + } catch (const std::ios_base::failure &failure) { + cout << "An IO failure occured when reading file from provided path: " << failure.what() << endl; } } @@ -333,8 +333,7 @@ void printMapsLink(const string &filePath) } else { throw Failure("At least one location is required to generate a link."); } - } catch (...) { - const char *what = ::IoUtilities::catchIoFailure(); - cout << "An IO failure occured when reading file from provided path: " << what << endl; + } catch (const std::ios_base::failure &failure) { + cout << "An IO failure occured when reading file from provided path: " << failure.what() << endl; } }