summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2018-05-26 10:01:26 +1000
committerMaxime Coste <mawww@kakoune.org>2018-05-26 10:01:26 +1000
commit54b62cbef7a534fed6278cc42c4df1f9ddc6b57a (patch)
tree3aed672d6b9f6bc4d737f4fa8e5f0e40c522456f
parent5e7574855698d0069a763c928ba51869af9a0776 (diff)
Do not expose C++ typeid().name to user facing errors on wrong option type
Fixes #2079
-rw-r--r--src/client.cc1
-rw-r--r--src/command_manager.cc1
-rw-r--r--src/completion.cc1
-rw-r--r--src/file.cc1
-rw-r--r--src/highlighters.cc1
-rw-r--r--src/hook_manager.cc1
-rw-r--r--src/input_handler.cc1
-rw-r--r--src/insert_completer.cc1
-rw-r--r--src/normal.cc1
-rw-r--r--src/option_manager.hh6
-rw-r--r--src/selectors.cc1
-rw-r--r--src/shell_manager.cc1
-rw-r--r--src/window.cc1
-rw-r--r--src/word_db.cc1
14 files changed, 17 insertions, 2 deletions
diff --git a/src/client.cc b/src/client.cc
index 8a0dfadb..f4e371ff 100644
--- a/src/client.cc
+++ b/src/client.cc
@@ -7,6 +7,7 @@
#include "file.hh"
#include "remote.hh"
#include "option.hh"
+#include "option_types.hh"
#include "client_manager.hh"
#include "command_manager.hh"
#include "event_manager.hh"
diff --git a/src/command_manager.cc b/src/command_manager.cc
index afa630da..9cf0c805 100644
--- a/src/command_manager.cc
+++ b/src/command_manager.cc
@@ -6,6 +6,7 @@
#include "context.hh"
#include "flags.hh"
#include "optional.hh"
+#include "option_types.hh"
#include "ranges.hh"
#include "register_manager.hh"
#include "shell_manager.hh"
diff --git a/src/completion.cc b/src/completion.cc
index e5a664b0..762a0413 100644
--- a/src/completion.cc
+++ b/src/completion.cc
@@ -1,6 +1,7 @@
#include "completion.hh"
#include "file.hh"
#include "context.hh"
+#include "option_types.hh"
#include "regex.hh"
namespace Kakoune
diff --git a/src/file.cc b/src/file.cc
index e3be4d78..00d7b627 100644
--- a/src/file.cc
+++ b/src/file.cc
@@ -4,6 +4,7 @@
#include "buffer.hh"
#include "exception.hh"
#include "flags.hh"
+#include "option_types.hh"
#include "ranked_match.hh"
#include "regex.hh"
#include "string.hh"
diff --git a/src/highlighters.cc b/src/highlighters.cc
index eafe8a4f..b537b76e 100644
--- a/src/highlighters.cc
+++ b/src/highlighters.cc
@@ -10,6 +10,7 @@
#include "highlighter_group.hh"
#include "line_modification.hh"
#include "option.hh"
+#include "option_types.hh"
#include "parameters_parser.hh"
#include "ranges.hh"
#include "regex.hh"
diff --git a/src/hook_manager.cc b/src/hook_manager.cc
index d0100467..378756c0 100644
--- a/src/hook_manager.cc
+++ b/src/hook_manager.cc
@@ -7,6 +7,7 @@
#include "display_buffer.hh"
#include "face_registry.hh"
#include "option.hh"
+#include "option_types.hh"
#include "ranges.hh"
#include "regex.hh"
diff --git a/src/input_handler.cc b/src/input_handler.cc
index f9710609..88dfa28a 100644
--- a/src/input_handler.cc
+++ b/src/input_handler.cc
@@ -10,6 +10,7 @@
#include "face_registry.hh"
#include "insert_completer.hh"
#include "normal.hh"
+#include "option_types.hh"
#include "regex.hh"
#include "register_manager.hh"
#include "hash_map.hh"
diff --git a/src/insert_completer.cc b/src/insert_completer.cc
index 42e9642e..86b02e64 100644
--- a/src/insert_completer.cc
+++ b/src/insert_completer.cc
@@ -11,6 +11,7 @@
#include "regex.hh"
#include "window.hh"
#include "word_db.hh"
+#include "option_types.hh"
#include "utf8_iterator.hh"
#include "user_interface.hh"
diff --git a/src/normal.cc b/src/normal.cc
index 5ade6398..598113fa 100644
--- a/src/normal.cc
+++ b/src/normal.cc
@@ -13,6 +13,7 @@
#include "file.hh"
#include "flags.hh"
#include "option_manager.hh"
+#include "option_types.hh"
#include "ranges.hh"
#include "regex.hh"
#include "register_manager.hh"
diff --git a/src/option_manager.hh b/src/option_manager.hh
index a7dc8ed2..f5d36ac0 100644
--- a/src/option_manager.hh
+++ b/src/option_manager.hh
@@ -182,7 +182,8 @@ template<typename T> const T& Option::get() const
{
auto* typed_opt = dynamic_cast<const TypedOption<T>*>(this);
if (not typed_opt)
- throw runtime_error(format("option '{}' is not of type '{}'", name(), typeid(T).name()));
+ throw runtime_error(format("option '{}' is not of type '{}'", name(),
+ option_type_name(Meta::Type<T>{})));
return typed_opt->get();
}
@@ -195,7 +196,8 @@ template<typename T> void Option::set(const T& val, bool notify)
{
auto* typed_opt = dynamic_cast<TypedOption<T>*>(this);
if (not typed_opt)
- throw runtime_error(format("option '{}' is not of type '{}'", name(), typeid(T).name()));
+ throw runtime_error(format("option '{}' is not of type '{}'", name(),
+ option_type_name(Meta::Type<T>{})));
return typed_opt->set(val, notify);
}
diff --git a/src/selectors.cc b/src/selectors.cc
index 4aecbef1..16d088b8 100644
--- a/src/selectors.cc
+++ b/src/selectors.cc
@@ -4,6 +4,7 @@
#include "context.hh"
#include "flags.hh"
#include "optional.hh"
+#include "option_types.hh"
#include "regex.hh"
#include "string.hh"
#include "unicode.hh"
diff --git a/src/shell_manager.cc b/src/shell_manager.cc
index a6d4a954..3615567e 100644
--- a/src/shell_manager.cc
+++ b/src/shell_manager.cc
@@ -10,6 +10,7 @@
#include "file.hh"
#include "flags.hh"
#include "option.hh"
+#include "option_types.hh"
#include "regex.hh"
#include <cstring>
diff --git a/src/window.cc b/src/window.cc
index 43ee52db..e8d99f33 100644
--- a/src/window.cc
+++ b/src/window.cc
@@ -9,6 +9,7 @@
#include "client.hh"
#include "buffer_utils.hh"
#include "option.hh"
+#include "option_types.hh"
#include <algorithm>
#include <sstream>
diff --git a/src/word_db.cc b/src/word_db.cc
index c9bd226a..585f6d8d 100644
--- a/src/word_db.cc
+++ b/src/word_db.cc
@@ -2,6 +2,7 @@
#include "utils.hh"
#include "line_modification.hh"
+#include "option_types.hh"
#include "utf8_iterator.hh"
#include "unit_tests.hh"