summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2013-04-11 13:57:35 +0200
committerMaxime Coste <frrrwww@gmail.com>2013-04-11 13:57:35 +0200
commit35d0d5b2eaad64a703f14e507746424d331d1c27 (patch)
tree392a5be82d2ff5c92c51cfb143628566894bdc12 /src
parentc699172110ec0e097b933e9ec0ecb3f0083d3c01 (diff)
exceptions: use const char* what() instead of String description()
Diffstat (limited to 'src')
-rw-r--r--src/assert.cc2
-rw-r--r--src/client_manager.cc8
-rw-r--r--src/exception.cc2
-rw-r--r--src/exception.hh10
-rw-r--r--src/main.cc4
-rw-r--r--src/remote.cc2
6 files changed, 14 insertions, 14 deletions
diff --git a/src/assert.cc b/src/assert.cc
index 4bd51a04..0e316be8 100644
--- a/src/assert.cc
+++ b/src/assert.cc
@@ -13,7 +13,7 @@ struct assert_failed : logic_error
assert_failed(const String& message)
: m_message(message) {}
- String description() const override { return m_message; }
+ const char* what() const override { return m_message.c_str(); }
private:
String m_message;
};
diff --git a/src/client_manager.cc b/src/client_manager.cc
index 006f4bed..b268df10 100644
--- a/src/client_manager.cc
+++ b/src/client_manager.cc
@@ -67,8 +67,8 @@ void ClientManager::create_client(std::unique_ptr<UserInterface>&& ui,
}
catch (Kakoune::runtime_error& error)
{
- context->print_status({ error.description(), get_color("Error") });
- context->hooks().run_hook("RuntimeError", error.description(), *context);
+ context->print_status({ error.what(), get_color("Error") });
+ context->hooks().run_hook("RuntimeError", error.what(), *context);
}
catch (Kakoune::client_removed&)
{
@@ -84,8 +84,8 @@ void ClientManager::create_client(std::unique_ptr<UserInterface>&& ui,
}
catch (Kakoune::runtime_error& error)
{
- context->print_status({ error.description(), get_color("Error") });
- context->hooks().run_hook("RuntimeError", error.description(), *context);
+ context->print_status({ error.what(), get_color("Error") });
+ context->hooks().run_hook("RuntimeError", error.what(), *context);
}
catch (Kakoune::client_removed&)
{
diff --git a/src/exception.cc b/src/exception.cc
index 7f378b6c..2b8fedc0 100644
--- a/src/exception.cc
+++ b/src/exception.cc
@@ -7,7 +7,7 @@
namespace Kakoune
{
-String exception::description() const
+const char* exception::what() const
{
return typeid(*this).name();
}
diff --git a/src/exception.hh b/src/exception.hh
index 0b68d39e..08647637 100644
--- a/src/exception.hh
+++ b/src/exception.hh
@@ -9,18 +9,18 @@ namespace Kakoune
struct exception
{
virtual ~exception() {}
- virtual String description() const;
+ virtual const char* what() const;
};
struct runtime_error : exception
{
- runtime_error(const String& description)
- : m_description(description) {}
+ runtime_error(String what)
+ : m_what(std::move(what)) {}
- String description() const override { return m_description; }
+ const char* what() const override { return m_what.c_str(); }
private:
- String m_description;
+ String m_what;
};
struct logic_error : exception
diff --git a/src/main.cc b/src/main.cc
index 97fc20b2..2bc487fc 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -986,7 +986,7 @@ int main(int argc, char* argv[])
}
catch (Kakoune::runtime_error& error)
{
- write_debug("error while parsing kakrc: " + error.description());
+ write_debug("error while parsing kakrc: "_str + error.what());
}
if (parser.positional_count() != 0)
@@ -1010,7 +1010,7 @@ int main(int argc, char* argv[])
}
catch (Kakoune::exception& error)
{
- on_assert_failed(("uncaught exception:\n" + error.description()).c_str());
+ on_assert_failed(("uncaught exception:\n"_str + error.what()).c_str());
return -1;
}
catch (std::exception& error)
diff --git a/src/remote.cc b/src/remote.cc
index ee80ebe3..8eb3c88b 100644
--- a/src/remote.cc
+++ b/src/remote.cc
@@ -450,7 +450,7 @@ private:
}
catch (runtime_error& e)
{
- write_debug("error running command '" + m_buffer + "' : " + e.description());
+ write_debug("error running command '" + m_buffer + "' : " + e.what());
}
ClientManager::instance().redraw_clients();
close(socket);