Skip to content
Snippets Groups Projects
Commit 5b06a8ac authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

error handling

parent bc5df8d7
No related branches found
No related tags found
No related merge requests found
......@@ -76,6 +76,7 @@ class Msg {
static double &Timer(std::string str){ return _timers[str]; }
static void PrintTimers();
static void ResetErrorCounter(){ _warningCount = 0; _errorCount = 0; }
static int GetErrorCount(){ return _errorCount; }
static void PrintErrorCounter(const char *title);
static double GetValue(const char *text, double defaultval);
static std::string GetString(const char *text, std::string defaultval);
......
......@@ -414,6 +414,19 @@ static bool incrementLoop()
return ret;
}
static bool stopOnError(const std::string &client)
{
if(Msg::GetErrorCount() > 0 && !CTX::instance()->expertMode){
Msg::ResetErrorCounter();
std::string msg
(client + " reported an error: do you really want to continue?\n\n"
"(To disable this warning in the future, select `Enable expert mode'\n"
"in the option dialog.");
if(Msg::GetAnswer(msg.c_str(), 1, "Stop", "Continue") == 0) return true;
}
return false;
}
void onelab_cb(Fl_Widget *w, void *data)
{
if(!data) return;
......@@ -442,6 +455,8 @@ void onelab_cb(Fl_Widget *w, void *data)
if(action == "compute") initializeLoop();
bool stop = false;
do{ // enter computation loop
// the Gmsh client is special: it always gets executed first. (The
......@@ -478,7 +493,6 @@ void onelab_cb(Fl_Widget *w, void *data)
geometry_reload_cb(0, 0);
if(FlGui::instance()->onelab->meshAuto()){
mesh_3d_cb(0, 0);
// FIXME: check if meshing succeeded
CreateOutputFile(mshFileName, CTX::instance()->mesh.fileFormat);
}
}
......@@ -486,13 +500,14 @@ void onelab_cb(Fl_Widget *w, void *data)
// mesh+save if the mesh file does not exist
if(FlGui::instance()->onelab->meshAuto()){
mesh_3d_cb(0, 0);
// FIXME: check if meshing succeeded
CreateOutputFile(mshFileName, CTX::instance()->mesh.fileFormat);
}
}
onelab::server::instance()->setChanged(false, "Gmsh");
}
}
stop = stopOnError("Gmsh");
if(stop) break;
// Iterate over all other clients
for(onelab::server::citer it = onelab::server::instance()->firstClient();
......@@ -516,11 +531,14 @@ void onelab_cb(Fl_Widget *w, void *data)
else if(action == "kill"){
c->kill();
}
stop = stopOnError(c->getName());
if(stop) break;
}
FlGui::instance()->onelab->rebuildTree();
} while(action == "compute" && incrementLoop());
} while(action == "compute" && incrementLoop() && !stop);
FlGui::instance()->onelab->activate();
FlGui::instance()->onelab->show();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment