Rework fail
command not to display command call stack
`fail` triggers "expected" errors, and hence should just display the provided message.
This commit is contained in:
parent
54b62cbef7
commit
68fb3ba88f
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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, " "))};
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -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
|
||||
{
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user