diff --git a/main.cpp b/main.cpp index f1b8246..ee9e6dd 100644 --- a/main.cpp +++ b/main.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -204,7 +205,7 @@ vector locationsFromFile(const string &path) fstream file; file.open(path, ios_base::in); if(!file) - throw ios_base::failure("Unable to open the file \"" + path + "\"."); + IoUtilities::throwIoFailure(("Unable to open the file \"" + path + "\".").data()); file.exceptions(ios_base::badbit); string line; vector locations; @@ -259,8 +260,9 @@ void printTrackLength(const string &filePath, bool circle) vector locations(locationsFromFile(filePath)); printDistance(Location::trackLength(locations, circle)); cout << " (" << locations.size() << " trackpoints)"; - } catch(ios_base::failure &ex) { - cout << "An IO failure occured when reading file from provided path: " << ex.what() << endl; + } catch(...) { + const char *what = ::IoUtilities::catchIoFailure(); + cout << "An IO failure occured when reading file from provided path: " << what << endl; } } @@ -328,7 +330,8 @@ void printMapsLink(const string &filePath) } else { throw Failure("At least one location is required to generate a link."); } - } catch(ios_base::failure &ex) { - cout << "An IO failure occured when reading file from provided path: " << ex.what() << endl; + } catch(...) { + const char *what = ::IoUtilities::catchIoFailure(); + cout << "An IO failure occured when reading file from provided path: " << what << endl; } }