Use a specific startup_error exception type to get a nicer message

Fixes #424
This commit is contained in:
Maxime Coste 2016-04-09 09:13:35 +01:00
parent 9b98aa61a8
commit d4b1138e2f

View File

@ -33,6 +33,11 @@
using namespace Kakoune;
struct startup_error : Kakoune::runtime_error
{
using Kakoune::runtime_error::runtime_error;
};
String runtime_directory()
{
char relpath[PATH_MAX+1];
@ -384,7 +389,7 @@ std::unique_ptr<UserInterface> create_local_ui(UIType ui_type)
};
if (not isatty(1))
throw runtime_error("stdout is not a tty");
throw startup_error("stdout is not a tty");
if (not isatty(0))
{
@ -837,6 +842,11 @@ int main(int argc, char* argv[])
generate_switches_doc(param_desc.switches)));
return -1;
}
catch (startup_error& error)
{
write_stderr(format("Could not start kakoune: {}\n", error.what()));
return -1;
}
catch (Kakoune::exception& error)
{
write_stderr(format("uncaught exception ({}):\n{}", typeid(error).name(), error.what()));