summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2018-05-26 13:07:03 +1000
committerMaxime Coste <mawww@kakoune.org>2018-05-26 21:31:17 +1000
commit68fb3ba88fc36982f583bd09189c3af4b0b00521 (patch)
treeda51d9bc9967456282652507263e915f1083f8b1 /src
parent54b62cbef7a534fed6278cc42c4df1f9ddc6b57a (diff)
Rework `fail` command not to display command call stack
`fail` triggers "expected" errors, and hence should just display the provided message.
Diffstat (limited to 'src')
-rw-r--r--src/command_manager.cc9
-rw-r--r--src/commands.cc2
-rw-r--r--src/exception.hh6
3 files changed, 14 insertions, 3 deletions
diff --git a/src/command_manager.cc b/src/command_manager.cc
index 9cf0c805..94182f4d 100644
--- a/src/command_manager.cc
+++ b/src/command_manager.cc
@@ -425,10 +425,15 @@ void CommandManager::execute_single_command(CommandParameters params,
command_it->value.param_desc);
command_it->value.func(parameter_parser, context, shell_context);
}
+ catch (failure& error)
+ {
+ throw;
+ }
catch (runtime_error& error)
{
- throw runtime_error(format("{}:{}: '{}' {}", pos.line+1, pos.column+1,
- params[0], error.what()));
+ error.set_what(format("{}:{}: '{}' {}", pos.line+1, pos.column+1,
+ params[0], error.what()));
+ throw;
}
}
diff --git a/src/commands.cc b/src/commands.cc
index febc8f33..213926f7 100644
--- a/src/commands.cc
+++ b/src/commands.cc
@@ -2140,7 +2140,7 @@ const CommandDesc fail_cmd = {
CommandCompleter{},
[](const ParametersParser& parser, Context&, const ShellContext&)
{
- throw runtime_error(fix_atom_text(join(parser, ' ', false)));
+ throw failure{fix_atom_text(join(parser, " "))};
}
};
diff --git a/src/exception.hh b/src/exception.hh
index 4967e15b..0ff3d825 100644
--- a/src/exception.hh
+++ b/src/exception.hh
@@ -18,11 +18,17 @@ struct runtime_error : exception
: m_what(std::move(what)) {}
StringView what() const override { return m_what; }
+ void set_what(String what) { m_what = std::move(what); }
private:
String m_what;
};
+struct failure : runtime_error
+{
+ using runtime_error::runtime_error;
+};
+
struct logic_error : exception
{
};