Skip to content

Commit

Permalink
error messages in cli
Browse files Browse the repository at this point in the history
  • Loading branch information
chistopher committed May 9, 2019
1 parent 6418b6b commit bd53c6f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion source/cli/gengirg/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
#include <string>
#include <cstring>
#include <fstream>
#include <algorithm>

#include <omp.h>

#include <girgs/girgs-version.h>
#include <girgs/Generator.h>
#include <girgs/BitManipulation.h>
#include <algorithm>


using namespace std;
Expand Down Expand Up @@ -152,6 +152,7 @@ int main(int argc, char* argv[]) {
cout << "writing edge list (.txt) ...\t" << flush;
auto t6 = high_resolution_clock::now();
ofstream f{file+".txt"};
if(!f.is_open()) throw std::runtime_error{"Error: failed to open file \"" + file + ".txt\""};
f << n << ' ' << edges.size() << "\n\n";
for(auto& each : edges)
f << each.first << ' ' << each.second << '\n';
Expand Down
2 changes: 2 additions & 0 deletions source/cli/genhrg/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ int main(int argc, char* argv[]) {
cout << "writing edge list (.txt) ...\t" << flush;
auto t6 = high_resolution_clock::now();
ofstream f{file+".txt"};
if(!f.is_open()) throw std::runtime_error{"Error: failed to open file \"" + file + ".txt\""};
f << n << ' ' << edges.size() << "\n\n";
for(auto& each : edges)
f << each.first << ' ' << each.second << '\n';
Expand All @@ -149,6 +150,7 @@ int main(int argc, char* argv[]) {
cout << "writing coordinates (.hyp) ...\t" << flush;
auto t6 = high_resolution_clock::now();
ofstream f{file+".hyp"};
if(!f.is_open()) throw std::runtime_error{"Error: failed to open file \"" + file + ".hyp\""};
f << std::fixed << std::setprecision(6);
for(auto i{0u}; i<n; ++i)
f << radii[i] << ' ' << angles[i] << '\n';
Expand Down
2 changes: 2 additions & 0 deletions source/girgs/source/Generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ void saveDot(const std::vector<double> &weights, const std::vector<std::vector<d
const std::vector<std::pair<int, int>> &graph, const std::string &file) {

std::ofstream f{file};
if(!f.is_open())
throw std::runtime_error{"Error: failed to open file \"" + file + '\"'};
f << "graph girg {\n\toverlap=scale;\n\n";
f << std::fixed;
for (int i = 0; i < weights.size(); ++i) {
Expand Down

0 comments on commit bd53c6f

Please sign in to comment.