Commit a39fa673 authored by GILLES Sebastien's avatar GILLES Sebastien

#1480 In Fact make GracefulExit inherit privately from std::exception; thus...

#1480 In Fact make GracefulExit inherit privately from std::exception; thus enabling a more tailored message on screen.
parent ecf26a3f
......@@ -19,13 +19,24 @@ namespace MoReFEM::ExceptionNS
GracefulExit::GracefulExit(const char* invoking_file, int invoking_line)
: MoReFEM::Exception("The code will stop now and return EXIT_SUCCESS.", invoking_file, invoking_line)
{ }
{
std::ostringstream oconv;
oconv << "A graceful exit of the program was required at file " << invoking_file << " and line "
<< invoking_line << ". The program will therefore end and return EXIT_SUCCESS.";
what_message_ = oconv.str();
}
GracefulExit::~GracefulExit() = default;
const char* GracefulExit::what() const noexcept
{
return what_message_.c_str();
}
} // namespace MoReFEM::ExceptionNS
......
......@@ -16,7 +16,7 @@
# define MOREFEM_x_UTILITIES_x_EXCEPTIONS_x_GRACEFUL_EXIT_HPP_
# include "Utilities/Exceptions/Exception.hpp"
# include <exception>
namespace MoReFEM::ExceptionNS
......@@ -24,12 +24,12 @@ namespace MoReFEM::ExceptionNS
//! Exception when we want to exit gracefull with a EXIT_SUCCESS return code.
class GracefulExit : private MoReFEM::Exception
class GracefulExit : private std::exception
{
public:
//! Alias to parent.
using parent = MoReFEM::Exception;
using parent = std::exception;
public:
......@@ -56,8 +56,18 @@ namespace MoReFEM::ExceptionNS
//! Destructor
virtual ~GracefulExit() override;
//! Making what() accessible publicly.
using parent::what;
/*!
* \brief Display the what message from std::exception.
*
* \return The what() message as a char* (which reads the internal std::string so no risk of deallocation
* issue).
*/
virtual const char* what() const noexcept override final;
private:
//! The complete what() message (with the location part)
std::string what_message_;
};
......
......@@ -42,6 +42,8 @@ namespace MoReFEM::FilesystemNS
std::string ComputeWildcardPath(const Directory& directory);
std::string XCodeWarning();
} // namespace anonymous
......@@ -109,6 +111,7 @@ namespace MoReFEM::FilesystemNS
{
std::ostringstream oconv;
oconv << "Directory '" << GetPath() << "' already exist. Do you want to remove it? [y/n]";
oconv << XCodeWarning();
AskCaseHelper(oconv.str());
}
}
......@@ -330,6 +333,7 @@ namespace MoReFEM::FilesystemNS
oconv << "Directories '" << wildcard_path << "' already exist for ranks " << rank_list
<< ". Do you want to remove them? [y/n]"<< std::endl;
oconv << XCodeWarning();
return AskCaseHelper(oconv.str());
}
......@@ -383,6 +387,13 @@ namespace MoReFEM::FilesystemNS
}
std::string XCodeWarning()
{
return "\tNote for XCode user: doesn't work in XCode in parallel.. You should consider "
"--overwrite_directory flag in the arguments on command line.";
}
} // namespace anonymous
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment