Commit ad80999d authored by Sebastian Wolf's avatar Sebastian Wolf

Let Exceptions now use stringstreams

parent 99366b97
Pipeline #1841 failed with stages
in 12 minutes and 18 seconds
......@@ -37,7 +37,7 @@ namespace xerus {
class generic_error : public std::exception {
public:
///@brief String containing all relevant information concerning this error.
std::string error_info;
std::stringstream error_info;
/// @brief: Normal constructor without preset error_info.
generic_error();
......@@ -52,7 +52,7 @@ namespace xerus {
template<typename error_t, class T>
typename std::enable_if<std::is_base_of<generic_error, error_t>::value, error_t&>::type
operator<< (error_t &o, const T &_info) noexcept {
o.error_info += to_string(_info);
o.error_info << to_string(_info);
return o;
}
......@@ -60,7 +60,7 @@ namespace xerus {
template<typename error_t, class T>
typename std::enable_if<std::is_base_of<generic_error, error_t>::value, error_t&>::type
operator<< (error_t &&o, const T &_info) noexcept {
o.error_info += to_string(_info);
o.error_info << to_string(_info);
return o;
}
}
......
......@@ -28,11 +28,12 @@ namespace xerus {
namespace misc {
generic_error::generic_error() {}
generic_error::generic_error(const generic_error &_other) noexcept
: error_info(_other.error_info) { }
generic_error::generic_error(const generic_error &_other) noexcept {
error_info << _other.error_info.rdbuf();
}
const char* generic_error::what() const noexcept {
return error_info.c_str();
return error_info.str().c_str();
}
} // namespace misc
......
......@@ -39,7 +39,7 @@
#pragma GCC diagnostic pop
namespace xerus { namespace misc {
void create_directories_for_file(const std::string& _path) {
if(_path.find('/') != std::string::npos) {
std::string folder = _path.substr(0, _path.find_last_of('/'));
......
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