From d4b1138e2fccd625479adf3a34cfa1d8a04a83ef Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sat, 9 Apr 2016 09:13:35 +0100 Subject: [PATCH] Use a specific startup_error exception type to get a nicer message Fixes #424 --- src/main.cc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main.cc b/src/main.cc index 35375c63..e14385ea 100644 --- a/src/main.cc +++ b/src/main.cc @@ -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 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()));