Do not expose C++ typeid().name to user facing errors on wrong option type

Fixes #2079
This commit is contained in:
Maxime Coste 2018-05-26 10:01:26 +10:00
parent 5e75748556
commit 54b62cbef7
14 changed files with 17 additions and 2 deletions

View File

@ -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"

View File

@ -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"

View File

@ -1,6 +1,7 @@
#include "completion.hh"
#include "file.hh"
#include "context.hh"
#include "option_types.hh"
#include "regex.hh"
namespace Kakoune

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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);
}

View File

@ -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"

View File

@ -10,6 +10,7 @@
#include "file.hh"
#include "flags.hh"
#include "option.hh"
#include "option_types.hh"
#include "regex.hh"
#include <cstring>

View File

@ -9,6 +9,7 @@
#include "client.hh"
#include "buffer_utils.hh"
#include "option.hh"
#include "option_types.hh"
#include <algorithm>
#include <sstream>

View File

@ -2,6 +2,7 @@
#include "utils.hh"
#include "line_modification.hh"
#include "option_types.hh"
#include "utf8_iterator.hh"
#include "unit_tests.hh"